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