473,326 Members | 2,805 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Unload a dll called via assembly

Hi everybody,

i´m working on an application that loads different modules (dll files)
via an assembly.
I check the build version in that dll file and if a newer version
exists, i want to update the file. There´s only one problem: once loaded
the library, i´m not able to delete it while the application is running.

Current function:

Dim AssemblyToLoad As [Assembly]
Dim ClassLibraryModule As [Module]
Dim FormType As Type
Dim AssemblyForm As Form
Dim PublicField As FieldInfo

AssemblyToLoad = [Assembly].LoadFrom(ModuleName)
ClassLibraryModule = AssemblyToLoad.GetModule(ModuleName)

FormType = ClassLibraryModule.GetType(ModuleName & ".ClassMain")

PublicField = FormType.GetField("VersionBuild")

return PublicField.GetValue(PublicField))

Application.DoEvents()

If the return value of the function is smaller as the VersionBuild of
the server dll, the dll file should be updated. But as long as the
program is running, the dll file is write protected.

How can i unload the assembly so the dll file isnt write protected anymore?

Please help!
Thanks, Andy
Sep 24 '05 #1
1 1888
You can unload an assembly from a .Net application but only by unloading the
appDomain that the assembly is loaded into. So if you don't create a
seperate appDomain when you are dynamically loading your assemblies you
won't be able to unload the assemblies.

check out the following links I found on google:

http://blogs.msdn.com/suzcook/archiv.../08/57211.aspx

As the blog says:

'...Maybe you don't need to load that Assembly, anyway. If you just need
info about it, you could call AssemblyName.GetAssemblyName() with the path
to the file...'

HTH

Ollie Riches

"Andy" <an*******@zwickau-net.de> wrote in message
news:Og*************@tk2msftngp13.phx.gbl...
Hi everybody,

i´m working on an application that loads different modules (dll files) via
an assembly.
I check the build version in that dll file and if a newer version exists,
i want to update the file. There´s only one problem: once loaded the
library, i´m not able to delete it while the application is running.

Current function:

Dim AssemblyToLoad As [Assembly]
Dim ClassLibraryModule As [Module]
Dim FormType As Type
Dim AssemblyForm As Form
Dim PublicField As FieldInfo

AssemblyToLoad = [Assembly].LoadFrom(ModuleName)
ClassLibraryModule = AssemblyToLoad.GetModule(ModuleName)

FormType = ClassLibraryModule.GetType(ModuleName & ".ClassMain")

PublicField = FormType.GetField("VersionBuild")

return PublicField.GetValue(PublicField))

Application.DoEvents()

If the return value of the function is smaller as the VersionBuild of the
server dll, the dll file should be updated. But as long as the program is
running, the dll file is write protected.

How can i unload the assembly so the dll file isnt write protected
anymore?

Please help!
Thanks, Andy

Sep 26 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Lloyd Sheen | last post by:
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...
4
by: Mirano | last post by:
Hi everybody. I load an assembly into another AppDomain, not a default one. As there is no way to unload the assembly, I need to unload the domain. This is where the app hangs. The problem is...
2
by: Patrick Blackman | last post by:
I have a program that search the application path for all the Dll that implement a certain interface IText ,when a Dll with the interface is found ,I run a method called IText.Format() which works...
2
by: Lauren Hines | last post by:
Hello, I have read numerous post stating that the only way to unload an assembly (DLL in my case) is to create a separate AppDomain, load the assembly, then unload it by calling AppDomain.Unload....
1
by: Luis Pinho | last post by:
Hi There, I've got a server that is waiting for requests, these request correspond to calls to objects that are specified in assemblies stored in the GAC. To do this, I use reflection to call...
2
by: Sam Martin | last post by:
Morning all, Right, I've read untold articles now, listening to people bitch about there being no Unload method for Assembly. Plenty of people do counter that this is possible by loading the...
6
by: Wal Turner | last post by:
Hi there. There are various snippets on forums regarding issues with AppDomain.Unload and how it just doesnt work. Fortunately, I got it working with the base case, after much fiddling. Consider...
2
by: brianbender | last post by:
I am trying to load and unload assemblies dynamically and call methods and properties when loaded into an Appdomain I can load assemblies all day in the current AppDomain without references and...
1
by: Andy | last post by:
Hi everybody, i´m working on an application that loads different modules (dll files) via an assembly. I check the build version in that dll file and if a newer version exists, i want to update...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.