Remote load returning MarshalByRefObject



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!

.



Relevant Pages

  • Re: Creating remote objects
    ... >> This creates an instance of Word on the local machine from Excel 2000, ... I don't have a remote server to go against. ... >> (ByVal lpszIID As String, ByVal piid As Long) As Long ... >> Dim rclsid As GUID ...
    (microsoft.public.excel.programming)
  • Re: Creating remote objects
    ... I don't have a remote server to go against. ... > (ByVal lpszIID As String, ByVal piid As Long) As Long ... > Dim rclsid As GUID ...
    (microsoft.public.excel.programming)
  • Re: FTP - cant upload a file using the MS Example
    ... > ' write data to the FTP Server to the spcified size below. ... > Private m_sMessageString As String ... > Public Sub New ... > ' Set/Get the remote path. ...
    (microsoft.public.dotnet.languages.vb)
  • Win32_Process.Create always returns 9
    ... i try to create a remote process with Win32_Process.Create, ... ExecuteProcessRemote_TrowsException(string TargetMachine, string ... ManagementScope manScope = new ... ObjectGetOptions objectGetOptions = new ObjectGetOptions; ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: INSERT FROM other table
    ... > need to retrieve data from one table, add a few new values in the same ... > script and save this data in a remote database table. ... > new columns to the remote database and want to set these values in the sql ... > string manually to mark the status or whatever. ...
    (microsoft.public.sqlserver.programming)

Loading