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)
------------------------------------------------------------------------- 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)
-------------------------------------------------------------------------
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)
-------------------------------------------------------------------------
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)
------------------------------------------------------------------------- This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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...
|
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...
|
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...
|
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....
| |
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...
|
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...
|
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...
|
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...
|
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,...
|
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...
| |
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...
|
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...
|
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: 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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |