Remote load returning MarshalByRefObject
- From: "Chris" <chris@xxxxxxxxxxxxxxxxxxx>
- Date: 11 Dec 2006 12:33:16 -0800
Hello,
I'm having a problem using a remote application domain to dynamically
load/unload dlls. My code works fine when run from a standalone
application, but when I run it as a plugin to another application, i
get an error saying that it cannot cast the return.
Here is the code:
public class BaseTransferDef
{
....
public class RemoteAssemblyLoader : MarshalByRefObject
{
public string[] Assemblies {get;}
public string[] GetTypes(string assemblyName, int type)
{get;}
public void LoadAssembly(string fileName);
}
private void InitAssemblyDomain()
{
UnInitAssemblyDomain();
AppDomain domain = AppDomain.CurrentDomain;
string cdiProgramPath =
Path.GetDirectoryName(typeof(BaseTransferDef).Assembly.Location);
//Create the new domain
AppDomainSetup setup = new AppDomainSetup();
setup.ApplicationBase = _tempDir.Path;
setup.PrivateBinPath = cdiProgramPath;
_loadedAssemblyDomain = AppDomain.CreateDomain(_projectName
+ "_LoadedAssemblies", null, setup);
string assemblyName =
typeof(RemoteAssemblyLoader).Assembly.Location;
string typeName = typeof(RemoteAssemblyLoader).FullName;
try
{
object remoteLoaderObj =
_loadedAssemblyDomain.CreateInstanceFromAndUnwrap(assemblyName,
typeName);
if (remoteLoaderObj is RemoteAssemblyLoader)
_remoteLoader =
(RemoteAssemblyLoader)remoteLoaderObj;
else
throw new Exception("Could not cast remote
loader.");
}
catch
{
UnInitAssemblyDomain();
throw;
}
So, it all works find in its own exe, but when it is run as a plugin,
the return is a MarshalByRefObject, not a RemoteAssemblyLoader (the
"Could not cast remote loader." exception is fired)
Does anybody have any ideas what is causing this? I saw one othe rpost
from 3 years ago on this, but have not found anything else.
Please help!
.
- Prev by Date: Re: MarshalByRefObject
- Next by Date: HTTPChannel and HTTP.SYS
- Previous by thread: Re: Remoting and Windows 98
- Next by thread: HTTPChannel and HTTP.SYS
- Index(es):
Relevant Pages
|
Loading