.net - How to determine whether a TransparentProxy points to a valid instance -


is there way determine whether transparentproxy pointing valid reference?

i have iplugin. create new appdomain, load assembly implementation of iplugin, , create instance of implemenation. receive iplugin, under covers transparentproxy. if unload secondary appdomain, instance of iplugin (the 1 proxy points to) gone. proxy still pointing there. program crashes (with no exceptions) when try access proxy.

psudeocode:

var domain = createdomain("domain"); var assembly = domain.loadassembly("myassembly"); var plugin = domain.createobject("myplugin") iplugin;  // plugin transparentproxy myplugin  if (plugin != null)     plugin.dosomething("123");  unloaddomain(domain);  if (plugin != null) // still evaluates true!     plugin.dosomething("123"); // program crashes no exceptions 

well, since no 1 has suggested proper answer, try this:

public static bool isvalidreference(marshalbyrefobject obj) {     try {         obj.equals(null);         return true;     } catch (remotingexception e) {         return false;     } } 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -