Hi! Sorry for my English. :)
Please consider the following code:
----------------------------------------------------------------------------
-
System.AppDomainSetup ap_setup = new System.AppDomainSetup();
ap_setup.LoaderOptimization = System.LoaderOptimization.MultiDomain;
AppDomain ap = AppDomain.CreateDomain("DomainForWork", null, ap_setup);
System.Security.Policy.Evidence pe = new System.Security.Policy.Evidence();
pe.AddAssembly(ap);
System.Reflection.Assembly a = ap.Load("Classes", pe);
System.Type t = a.GetType( "Global" );
System.Reflection.MethodInfo mi = t.GetMethod("InitColl");
mi.Invoke(null, null);
System.AppDomainSetup ap_setup2 = new System.AppDomainSetup();
ap_setup2.LoaderOptimization = System.LoaderOptimization.MultiDomain;
AppDomain ap2 = AppDomain.CreateDomain("DomainForWork2", null, ap_setup2);
System.Security.Policy.Evidence pe2 = new System.Security.Policy.Evidence();
pe2.AddAssembly(ap2);
System.Reflection.Assembly a2 = ap2.Load("Classes", pe2);
System.Type t2 = a2.GetType( "Global" );
System.Reflection.MethodInfo mi2 = t2.GetMethod("InitColl");
mi2.Invoke(null, null);
----------------------------------------------------------------------------
-
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?