VS.NET Extensibility, AppDomains & Assembly Unloading
Andres Aguiar <[email protected]> Mon, 17 Jun 2002 13:34:36 -0700
| Newsgroups | gmane.comp.windows.devel.dotnet.general |
|---|---|
| Message-ID | <DOTNET%[email protected]> |
We've built a number of Visual Studio Add-ins that read the assemblies that
are generated by the projects inside the current solution, and generate new
projects based on the formers.
After we run an add-in, the project assembly keeps loaded, so we can't
rebuild the project.
Based on the code from Eric Gunnerson's article on AppDomains And Dynamic
Loading [1], we used a different AppDomain to load the project assemblies.
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.
Any ideas?
Andres Aguiar
DeKlarit
www.deklarit.com
[1] http://msdn.microsoft.com/library/en-us/dncscol/html/csharp05162002.asp
You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.