4

私の c# プログラムは複数の appdomain を使用してアセンブリをロード/アンロードしています。2 番目の appdomain の私のアセンブリは、MarshalByRefObject を継承するオブジェクトを返しています。

私の問題は、Visual Studio がそれに関する情報を表示できないことを教えてくれることです。

透過プロキシのランタイム タイプの取得は、このコンテキストではサポートされていません。

2 番目の appdomain のクラスにいるときに、このオブジェクトに関する情報を確認できます。

私の質問: Visual Studio にこのオブジェクトに関する情報を 1. appdomain に表示するように指示することは何とか可能ですか?

編集:

解決策を見つけましたが、これは単なる回避策です。json との間でオブジェクトをシリアライズおよびデシリアライズして、クリーン コピーを取得します。

var info = Proxy.GetAssemblyInfo(assemblyPath, typeof(IMyAssembly));
#if DEBUG //just to have a debuggable object 
    var jsonSerializer = new JavaScriptSerializer();
    var json = jsonSerializer.Serialize(info);
    info = jsonSerializer.Deserialize<AppDomainAssemblyInfo>(json);
#endif

reutrn info;

しかし、より良い解決策があれば教えてください:)

編集2:

詳細に説明するコード:

var secondAppDomain = CreateAppDomain();

AppDomainLoaderProxy proxy = appDomain.CreateInstanceAndUnwrap(typeof(AppDomainLoaderProxy).Assembly.FullName, typeof(AppDomainLoaderProxy).FullName) as AppDomainLoaderProxy;

var myReturnValue = proxy.getSomeInformation();

//myReturnValue is not debuggable. When I add this to watch-list, VS tells me:
//Obtaining the runtime type of a transparent proxy is not supported in this context.
4

0 に答える 0