unloading an assembly

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

I remember reading somewhere that assemblies can be loaded but not unloaded... I
can't seem to find where I read it, but I am looking at a problem where I need
to load up an assembly from a file name and path, analyze it, then put it away
(without shutting down the app) so that it can be recomipled later if someone
else is working with it. I was thinking perhaps I could get around this by
calling a separate exe to do the work and then just terminate the process when
it's complete, but I thought there might be a simpler approach to this type of
problem. Suggestions?

TIA,
Bob
 
Try creating a seperate AppDomain, loading the assembly into that AppDomain,
then getting rid of the AppDomain.
If you do a search using AppDomain, you'll find some examples.

-Rob Teixeira [MVP]
 
* "Bob said:
I remember reading somewhere that assemblies can be loaded but not unloaded... I
can't seem to find where I read it, but I am looking at a problem where I need
to load up an assembly from a file name and path, analyze it, then put it away
(without shutting down the app) so that it can be recomipled later if someone

Load it into a separate 'AppDomain' and unload this app domain.

Sample in C#:

<http://www.codeproject.com/csharp/livecodedotnet.asp>
 
Strange, I've learned C# pretty well simply by needing to read examples.

Thanks, Harfried, for such an interesting example.

Bob
 
I can't get this to work for my own purposes. In VB the compiler demands at
runtime that the class being created by the factory class needs to be
serializable. When I make it so and it runs, a reference is created that locks
the file, which is what I wanted to avoid. Any ideas?

Bob
 
Never mind, I forgot to put MarshalByRefObject in the factory-created class,
after getting my code working in C#. Oh my god, I don't know how people write in
that language. The case sensitvity alone drives me up the wall.

Toss out that awful CodeModel, here comes my first plugin using Reflection! :)

Bob

Bob said:
I can't get this to work for my own purposes. In VB the compiler demands at
runtime that the class being created by the factory class needs to be
serializable. When I make it so and it runs, a reference is created that locks
the file, which is what I wanted to avoid. Any ideas?

Bob
 
Back
Top