On 5/11/05, MrJB <[EMAIL PROTECTED]> wrote:
<snip>
> 
> We have dll named "Classes" and we load it in two different application
> domains.
> 
> Then we successfully call static method named "InitColl" in the first
> domain, but
> 
> if we call this method in second domain after calling it in the first
> domain, we
> 
> have an exception. Why call of this method in the second domain is able to
> see
> 
> changes that was made by it in first domain? Does anyone know what's the
> problem?

In case you've not got anywhere with this, I replicated your code in
VB.NET and it worked:

---- AppDomTest.vb ----
Option Explicit On
Option Strict On

Module ADTest
Sub Main()
Dim ap_setup As New System.AppDomainSetup()
ap_setup.LoaderOptimization = System.LoaderOptimization.MultiDomain
Dim ap As AppDomain = AppDomain.CreateDomain("DomainForWork", Nothing, ap_setup)
Dim pe As New System.Security.Policy.Evidence()
pe.AddAssembly(ap)
Dim a As System.Reflection.Assembly = ap.Load("Classes", pe)
Dim t As System.Type = a.GetType("Global")
Dim mi As System.Reflection.MethodInfo = t.GetMethod("InitColl")
mi.Invoke(Nothing, Nothing)


Dim ap_setup2 As New System.AppDomainSetup()
ap_setup2.LoaderOptimization = System.LoaderOptimization.MultiDomain
Dim ap2 As AppDomain = AppDomain.CreateDomain("DomainForWork2",
Nothing, ap_setup2)
Dim pe2 As New System.Security.Policy.Evidence()
pe2.AddAssembly(ap2)
Dim a2 As System.Reflection.Assembly = ap2.Load("Classes", pe2)
Dim t2 As System.Type = a2.GetType("Global")
Dim mi2 As System.Reflection.MethodInfo = t2.GetMethod("InitColl")
mi2.Invoke(Nothing, Nothing)
End Sub
End Module
--- Ends ---

--- Classes.vb ---
' Compiled to Classes.dll
Option Explicit On
Option Strict On

Module Global
Sub InitColl()
 MsgBox("InitColl called")
End Sub
End Module
--- Ends ---

So it's probably somthing else. Can InitColl throw the exception you're getting?

Regards,
Mark Hurd, B.Sc.(Ma.)(Hons.)

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to