473,410 Members | 1,950 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,410 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 1891
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.