Unload an Assembly loaded via Assembly.LoadFrom()

  • Thread starter Thread starter GD
  • Start date Start date
G

GD

Hi,

The following code gets version number from an executable file. After
getting the version number, I need to delete the file. Since the file is
loaded into memory, the file cannot be deleted without unloading it. The
problem is that Compact Framework doesn't have a unload method. Is there any
work around?

Thanks.

GD

-------------------Sample code-----------------------

Assembly asmExe = Assembly.LoadFrom(AProg.exe);

AssemblyName asmName = asmExe .GetName();

MessageBox.Show(asmName.Version.ToString());

File.Delete(AProg.exe); //Error occurs
 
Hello, GD!

G> The following code gets version number from an executable file. After
G> getting the version number, I need to delete the file. Since the file is
G> loaded into memory, the file cannot be deleted without unloading it. The
G> problem is that Compact Framework doesn't have a unload method. Is there
G> any work around?

Take a look at
( http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp05162002.asp )
The same AFAIK can be applied to Compact Framework
--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
 
Hi Vadym,

Thanks very much for your reference.

I believe that the solution in the article doesn't applies to compact
framework since some key functions are missing in compact framework such as
AppDomain.Unload and AppDomain.CreateInstanceAndUnwrap methods.

Please correct me if I am wrong.

Regards,

GD
 
Hello, GD!
You wrote on Tue, 8 Aug 2006 14:14:17 -0500:

G> Thanks very much for your reference.

G> I believe that the solution in the article doesn't applies to compact
G> framework since some key functions are missing in compact framework such
G> as AppDomain.Unload and AppDomain.CreateInstanceAndUnwrap methods.

My docs say that Compact Framework 2.0 contains method AppDomain.Unload.
And AppDomain.CreateInstanceAndUnwrap can be substituted with
AppDomain.ExecuteAssembly
 
Hi Vadym,

I am using still CF 1.0. No wonder I didn' t find the Unload method. Since I
have to stick to CF 1.0, I have to find another solution.

Thanks anyway.

GD
 
Back
Top