473,503 Members | 3,722 Online
Bytes | Software Development & Data Engineering Community
+ 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 1653
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
1546
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
1477
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
1898
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
6075
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
10819
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
11952
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
4337
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
7192
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
7064
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7261
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
7315
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
7445
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
3158
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
1492
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
721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
369
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.