How to debug appdomain return values in VS

梦想与她 提交于 2020-01-04 04:27:05

问题


my c# programm is using multiple appdomains to load/unload assemblies. My assemblies in the 2nd appdomain are returning an object which inherits MarshalByRefObject.

My Problem now is that Visual Studio tells me that it can't Show information about it.

Obtaining the runtime type of a transparent proxy is not supported in this context.

I can see information about this object when I'm in a class of the 2nd appdomain.

My question now: is it somehow possible to tell Visual Studio to Show me information about this object in 1. appdomain?

Edit:

I found a solution but this is just a Workaround. I serialize and deserialize the object from/to json to get a clean copy.

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;

but if there is a nicer solution please let me know :)

Edit 2:

Some Code to explain it in detail:

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.

来源:https://stackoverflow.com/questions/36098911/how-to-debug-appdomain-return-values-in-vs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!