On Sat, 22 Jun 2002 21:49:16 -0700, Keith Hill <[EMAIL PROTECTED]>
wrote:

>>The code runs perfect when we try it from a WinForm C# project, but it
>does
>>not work when we call it from inside the Visual Studio .NET AddIn (running
>>in the Visual Studio.NET default AppDomain). We get a casting exception
>>when we get the 'remote' instance in the following line:
>>
>>remoteLoader = (RemoteLoader)
>>    appDomain.CreateInstanceFromAndUnwrap(assemblyName, remoteClassName);
>>
>>the debugger says that the returned instance's type is MarshalByRef when
>>running from the Visual Studio.NET Addin, and it says that the type
>>is 'RemoteLoader' (that is what we want) when we run it from another
>>application.
>
>Wow. Just ran into this problem today.  I think we got around it by using
>reflection and MethodInfo.Invoke() to avoid the type cast but that is
>gross.  I would also love to know how to make this work.

OK, got this to work by either dropping the RemoteLoader assembly into
either the GAC or VS.NET's PrivateAssemblies directory.  The basic problem
is the code that does the cast is running within VS.NET, which has its own
appbase which most likely doesn't include the directory containing your
assembly (unless you drop your assembly into PrivateAssemblies or the GAC).

--
Keith

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to