Unload an Assembly loaded via Assembly.LoadFrom()

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
 
V

Vadym Stetsyak

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
 
G

GD

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
 
V

Vadym Stetsyak

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
 
G

GD

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
 

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