出力タイプが netmodule の C# コードを作成しました。これは C++ コードで使用されています。
既に読み込まれている同じアセンブリのオブジェクトを作成したいと考えています。ただし、別の AppDomain で。しかし、これを行うと、アセンブリを読み込んで CreateInstanceAndUnwrap メソッドを使用してオブジェクトを作成することができません。スタンドアロンの C# コードを使用して同じことをしようとすると、正常に動作します。
C++:
TestClass __gc *testObj;
testObj = AppDomainProcessor::getInstance()->newTestObj((LPWSTR)domName);
//testObj->otherOperation...
C#
namespace TestNS {
public class AppDomainProcessor {
...
public TestClass newTestObj(String domName) {
AppDomain appDomain = AppDomain.CreateDommain(domName);
TestClass testObj = (TestClass)appDomain.CreateInstanceAndUnwrap(typeof(TestClass).Assembly.FullName,typeof(TestClass).FullName);
//Could not load file or assembly 'MyManaged, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified
return testObj;
}
...
}
public class TestClass : MarshalByRefObject {
...
}
}
AssemblyName を出力したところ、C++ コードからコンパイルされた dll の名前として見つかりました。スタンドアロンの C# から試した場合は、exe の名前でした。
C++ と C# を一緒に使用する場合、これは AppDomain を作成する適切な方法ですか? または、AppDomain の作成を間違えました。手伝ってください。