AppDomain lAppDomain = null;
AppDomainManager appDomainManager = new AppDomainManager();
AppDomainSetup lDomainSetup = new AppDomainSetup();
lDomainSetup.ApplicationName = "OtherAppDomain";
lDomainSetup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
lDomainSetup.PrivateBinPath = "bin";
lDomainSetup.CachePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "cache\\");
lDomainSetup.ShadowCopyFiles = "true";
lDomainSetup.ShadowCopyDirectories = @"C:\Users\gagan.dhamija\Desktop\My project\MainClass\MainClass\bin\Debug\MainClass.dll";
lAppDomain = appDomainManager.CreateDomain("OtherDomain", null, lDomainSetup);
lAppDomain.Load("MainClass");
lAppDomain.InitializeLifetimeService();
Assembly[] CollectionAssembly = lAppDomain.GetAssemblies();
foreach (Assembly assembly in CollectionAssembly)
{
if (assembly.FullName == "MainClass, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")
Exportedvalues = GetAllExportedTypes(assembly);
}
MessageBox.Show("Loaded Assembly succesfully");
이 내가 사용하지만, 변경
이 완전히 옳지 않다을 반영하고 있지 않다 무엇을, 나는 특히 네이티브 DLL을 호출하는 관리되는 DLL이 문제로 실행했습니다. 특히 눈에 띄는 '메모리 누수'문제를 일으키는 오래된 dll 거주자의 경우. – user44298
@ivo s : 조심하지 않으면 당연히 문제가 될 것입니다. 특히 appdomain 경계 위로 뛰어 오르는 어셈블리/유형이있어 언로드가 불가능합니다. 그러나 그것은 완전히 다른 문제입니다. – leppie
@leppie : 당신이하고있는 일을 알지 못하면 접근법 변경 결정에 며칠을 보낼 수 있습니다. 나는 실제적으로 저자가 어려움에 처하게 될 것이라고 확신한다. – user44298