问题
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