By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,041 Members | 1,056 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,041 IT Pros & Developers. It's quick & easy.

unload a loaded assembly

P: n/a
I want to make a program that checks for updates at start...
The way I am doing this is to create 2 projects...

A simple exe checks the server for the version and downloads a dll if
needed.
The dll contains the program itself (so simple a form out of that dll is
started).

My problem is that the exe loads the dll ([Assembly].LoadFrom(..)) and gets
the version of that assembly to find out if an update is needed.
If an update is needed, I need to unload that assembly to be able to
overwrite the previously loaded dll.

Anybody an idea how to do this?
Dominique
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
* "Dominique Vandensteen" <domi.vds_insert@tralala_tenforce.com> scripsit:
A simple exe checks the server for the version and downloads a dll if
needed.
The dll contains the program itself (so simple a form out of that dll is
started).

My problem is that the exe loads the dll ([Assembly].LoadFrom(..)) and gets
the version of that assembly to find out if an update is needed.
If an update is needed, I need to unload that assembly to be able to
overwrite the previously loaded dll.


Load the assembly into a separate appdomain and unload the appdomain.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2

P: n/a
still can't delete the file...
am I doing something wrong?

my code:

dim filename as String = "c:\myfile.dll"
dim filebyte() as Byte = LoadFile(filename)

Dim versionDomain As AppDomain =
AppDomain.CreateDomain("DummyToCheckVersion")
Dim a As [Assembly] = versionDomain.Load(filebytes)
Dim version As Version = a.GetName.Version
AppDomain.Unload(versionDomain)

File.Delete(filename)
the delete fails:
An unhandled exception of type 'System.UnauthorizedAccessException' occurred
in mscorlib.dll
Additional information: Access to the path "c:\myfile.dll" is denied.


"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:bu************@ID-208219.news.uni-berlin.de...
* "Dominique Vandensteen" <domi.vds_insert@tralala_tenforce.com> scripsit:
A simple exe checks the server for the version and downloads a dll if
needed.
The dll contains the program itself (so simple a form out of that dll is
started).

My problem is that the exe loads the dll ([Assembly].LoadFrom(..)) and gets the version of that assembly to find out if an update is needed.
If an update is needed, I need to unload that assembly to be able to
overwrite the previously loaded dll.


Load the assembly into a separate appdomain and unload the appdomain.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.