473,495 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Cant unload assembly

Hi,

i tried to load an assembly to an appdomain. The data output is
correctly but the assembly is still in use after unloading the appdomain...

What am I doing wrong?
Please help!
My current code:

-------------------------------------------------------------------------

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

' Application Domain
Dim AppdomainSetup As New AppDomainSetup
Dim baseEvidence As Evidence = AppDomain.CurrentDomain.Evidence
Dim evidence As New Evidence(baseEvidence)
Dim newDomain As AppDomain

' Files
Dim Directory As Directory
Dim ModuleName As String
Dim File As File
ModuleName = "Testmodule.dll"

' Load assembly from file
AppdomainSetup.ApplicationBase = Application.StartupPath

AssemblyToLoad = [Assembly].LoadFrom(ModuleName, evidence)

newDomain = AppDomain.CreateDomain("Module", evidence, AppdomainSetup)

' Load the class library
ClassLibraryModule = AssemblyToLoad.GetModule(ModuleName)

' define start form
ModuleName = Replace(ModuleName, ".dll", "", , , CompareMethod.Text)
FormType = ClassLibraryModule.GetType(ModuleName & ".Frm_Main")

PublicField = FormType.GetField("Build")
msgbox("Current build: " & PublicField.GetValue(PublicField))

newDomain.Unload(newDomain)
-------------------------------------------------------------------------
Oct 12 '05 #1
3 1652
You have to wrap all accesses to the other assembly within a remoted object
running in the context of the second appdomain.

"Andy" <an*******@zwickau-net.de> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi,

i tried to load an assembly to an appdomain. The data output is correctly
but the assembly is still in use after unloading the appdomain...

What am I doing wrong?
Please help!
My current code:

-------------------------------------------------------------------------

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

' Application Domain
Dim AppdomainSetup As New AppDomainSetup
Dim baseEvidence As Evidence = AppDomain.CurrentDomain.Evidence
Dim evidence As New Evidence(baseEvidence)
Dim newDomain As AppDomain

' Files
Dim Directory As Directory
Dim ModuleName As String
Dim File As File
ModuleName = "Testmodule.dll"

' Load assembly from file
AppdomainSetup.ApplicationBase = Application.StartupPath

AssemblyToLoad = [Assembly].LoadFrom(ModuleName, evidence)

newDomain = AppDomain.CreateDomain("Module", evidence, AppdomainSetup)

' Load the class library
ClassLibraryModule = AssemblyToLoad.GetModule(ModuleName)

' define start form
ModuleName = Replace(ModuleName, ".dll", "", , , CompareMethod.Text)
FormType = ClassLibraryModule.GetType(ModuleName & ".Frm_Main")

PublicField = FormType.GetField("Build")
msgbox("Current build: " & PublicField.GetValue(PublicField))

newDomain.Unload(newDomain)
-------------------------------------------------------------------------

Oct 13 '05 #2
Hi,

sorry, but i couldn't follow your advice. Could you explain that to me
stricter?

Thanks,
Andy

David Levine wrote:
You have to wrap all accesses to the other assembly within a remoted object
running in the context of the second appdomain.

"Andy" <an*******@zwickau-net.de> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi,

i tried to load an assembly to an appdomain. The data output is correctly
but the assembly is still in use after unloading the appdomain...

What am I doing wrong?
Please help!
My current code:

-------------------------------------------------------------------------

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

' Application Domain
Dim AppdomainSetup As New AppDomainSetup
Dim baseEvidence As Evidence = AppDomain.CurrentDomain.Evidence
Dim evidence As New Evidence(baseEvidence)
Dim newDomain As AppDomain

' Files
Dim Directory As Directory
Dim ModuleName As String
Dim File As File
ModuleName = "Testmodule.dll"

' Load assembly from file
AppdomainSetup.ApplicationBase = Application.StartupPath

AssemblyToLoad = [Assembly].LoadFrom(ModuleName, evidence)

newDomain = AppDomain.CreateDomain("Module", evidence, AppdomainSetup)

' Load the class library
ClassLibraryModule = AssemblyToLoad.GetModule(ModuleName)

' define start form
ModuleName = Replace(ModuleName, ".dll", "", , , CompareMethod.Text)
FormType = ClassLibraryModule.GetType(ModuleName & ".Frm_Main")

PublicField = FormType.GetField("Build")
msgbox("Current build: " & PublicField.GetValue(PublicField))

newDomain.Unload(newDomain)
-------------------------------------------------------------------------


Oct 13 '05 #3
This link does a pretty good job of explaining the basic concepts.
http://www.gotdotnet.com/team/clr/AppdomainFAQ.aspx
"Andy" <an*******@zwickau-net.de> wrote in message
news:Op*************@TK2MSFTNGP09.phx.gbl...
Hi,

sorry, but i couldn't follow your advice. Could you explain that to me
stricter?

Thanks,
Andy

David Levine wrote:
You have to wrap all accesses to the other assembly within a remoted
object running in the context of the second appdomain.

"Andy" <an*******@zwickau-net.de> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi,

i tried to load an assembly to an appdomain. The data output is
correctly but the assembly is still in use after unloading the
appdomain...

What am I doing wrong?
Please help!
My current code:

-------------------------------------------------------------------------

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

' Application Domain
Dim AppdomainSetup As New AppDomainSetup
Dim baseEvidence As Evidence = AppDomain.CurrentDomain.Evidence
Dim evidence As New Evidence(baseEvidence)
Dim newDomain As AppDomain

' Files
Dim Directory As Directory
Dim ModuleName As String
Dim File As File
ModuleName = "Testmodule.dll"

' Load assembly from file
AppdomainSetup.ApplicationBase = Application.StartupPath

AssemblyToLoad = [Assembly].LoadFrom(ModuleName, evidence)

newDomain = AppDomain.CreateDomain("Module", evidence, AppdomainSetup)

' Load the class library
ClassLibraryModule = AssemblyToLoad.GetModule(ModuleName)

' define start form
ModuleName = Replace(ModuleName, ".dll", "", , , CompareMethod.Text)
FormType = ClassLibraryModule.GetType(ModuleName & ".Frm_Main")

PublicField = FormType.GetField("Build")
msgbox("Current build: " & PublicField.GetValue(PublicField))

newDomain.Unload(newDomain)
-------------------------------------------------------------------------


Oct 14 '05 #4

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

Similar topics

0
1538
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...
0
1471
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...
1
1896
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...
4
6074
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
10815
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
11948
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
4333
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
8168
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...
3
314
by: Andy | last post by:
Hi, i tried to load an assembly to an appdomain. The data output is correctly but the assembly is still in use after unloading the appdomain... What am I doing wrong? Please help! My...
0
7160
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
7196
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...
1
6878
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
7373
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...
1
4897
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...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1405
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
649
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.