cotopboy
9/2/2013 - 8:02 AM

dynamic load libary

dynamic load libary

AppDomainSetup appDomainSetup=new AppDomainSetup();
appDomainSetup.LoaderOptimization=LoaderOptimization.SingleDomain; 
System.Security.Policy.Evidence evidence = new System.Security.Policy.Evidence ();
AppDomain ad = AppDomain.CreateDomain("LabMapDotNetDomain", new System.Security.Policy.Evidence (),appDomainSetup); 



string DllPath = Application.StartupPath + @"\LabMapDotNet.dll ";
System.Reflection.Assembly assmble = System.Reflection.Assembly.LoadFile(DllPath);
Type tmpType = assmble.GetType("LabMapDotNet.LabMap");
System.Reflection.PropertyInfo proInfo = tmpType.GetProperty("Instance");
object obj = proInfo.GetValue(null, null);
labmap = obj as ILabMap;

Thread.Sleep(5000);
AppDomain.Unload(ad);