How to unload an assembly that is loaded with Assembly.LoadForm

L

Lloyd Sheen

I am having trouble gettting an assembly loaded with Assembly.LoadFrom.

I can get the assembly call the method I need to call. Now I want to unload
the assembly. I need to do this so that the user can (thru my app) create a
new version of the assembly. The app will call a predetermined method (sort
of an add-in) and then exit. At this point if the output is not what the
user wants , the GUI will allow the user to edit the source code that
created the assembly and recompile it. Not being able to unload means that
the compile will fail as it attempts to create the DLL.

I have tried creating an AppDomain, adding the assembly and then after
calling the method using the appdomain.unload. This does not free up the
dll.

Any ideas??

Lloyd Sheen
 
D

Dmitriy Krasnikov

I am having trouble gettting an assembly loaded with Assembly.LoadFrom.

I can get the assembly call the method I need to call. Now I want to unload
the assembly. I need to do this so that the user can (thru my app) create a
new version of the assembly. The app will call a predetermined method (sort
of an add-in) and then exit. At this point if the output is not what the
user wants , the GUI will allow the user to edit the source code that
created the assembly and recompile it. Not being able to unload means that
the compile will fail as it attempts to create the DLL.

I have tried creating an AppDomain, adding the assembly and then after
calling the method using the appdomain.unload. This does not free up the
dll.

Any ideas??

Lloyd Sheen
Don't use LoadFrom use Load. Read the file to byte[], close stream and
load byte[]. Then you can delete the file or overwrite it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top