我的 c# 程序正在使用多个 appdomains 来加载/卸载程序集。我在第二个 appdomain 中的程序集正在返回一个继承 MarshalByRefObject 的对象。
我现在的问题是 Visual Studio 告诉我它无法显示有关它的信息。
此上下文不支持获取透明代理的运行时类型。
当我在第二个应用程序域的类中时,我可以看到有关此对象的信息。
我现在的问题是:是否有可能告诉 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.