同様の質問がたくさん見つかりましたが、解決策が見つかりませんでした。
私は次のコードを持っています:
string file = "c:\\abc.dll";
AppDomainSetup ads = new AppDomainSetup();
ads.PrivateBinPath = Path.GetDirectoryName(file);
AppDomain ad2 = AppDomain.CreateDomain("AD2", null, ads);
ProxyDomain proxy = (ProxyDomain)ad2.CreateInstanceAndUnwrap(typeof(ProxyDomain).Assembly.FullName, typeof(ProxyDomain).FullName);
Assembly asm = proxy.GetAssembly(file); // exception File.IO assembly not found is thrown here after succesfully running the funktion GetAssembly.
public class ProxyDomain : MarshalByRefObject
{
public Assembly GetAssembly(string assemblyPath)
{
try
{
Assembly asm = Assembly.LoadFile(assemblyPath);
//...asm is initialized correctly, I can see everything with debugger
return asm;
}
catch
{
return null;
}
}
}
最も興味深いのは、GetAssembly 関数が他の型を返すことです。カスタムのシリアル化可能なクラスであっても、すべて問題ありません。誰かが私が欠けているものを知っていますか? または、ロードされたアセンブリを別のドメインに戻すことは不可能ですか?
ありがとうございました