Static News Archive

   (18-Aug-08 0:09)  Unloading an assembly
If you are loading an assembly dynamically in .net using Assembly.LoadFile(sPath), you may find it difficult to subsequently delete that assembly file until your appdomain has been unloaded.

This blogger suggest loading the assembly into an entirely different app domain, which will probably work nicely.
However, an alternative way is to get the bytes from the assembly, and load the assembly using the bytes.:

Assembly assembly = null;
//Load the assembly from the data
byte[] assemblyData = File.ReadAllBytes(GetFilePath(sPath));
assembly = Assembly.Load(assemblyData);

Now you can use the assembly as you wish, and still delete the assembly file.

Post a comment     

<-  (29-Jul-08 20:08)  Fun... (2-Sep-08 16:16)  Teched 2008 (tenz08)...  ->