remoting - How to pass an unknown type between two .NET AppDomains? -


i have .net application in assemblies in separate appdomains must share serialized objects passed value.

both assemblies reference shared assembly defines base class server class , defines base class entiy type passed between domains:

public abstract class serverbase : marshalbyrefobject {     public abstract entitybase getentity(); }  [serializable] public abstract class entitybase { } 

the server assembly defines server class , concrete implemetation of entity type:

public class server : serverbase {     public override entitybase getentity()     {         return new entityitem();     } }  [serializable] public class entityitem : entitybase { } 

the client assembly creates appdomain in server assembly hosted , uses instance of server class request concrete instance of entity type:

class program {     static void main()     {         var domain = appdomain.createdomain("server");          var server = (serverbase)activator.createinstancefrom(             domain,             @"..\..\..\server\bin\debug\server.dll",             "server.server").unwrap();          var entity = server.getentity();     } } 

unfortnately, approach fails serializationexception because client assembly has no direct knowledge of concrete type being returned.

i have read .net remoting supports unknown types when using binary serialization, not sure whether applies setup or how configure it.

alternatively, there other way of passing unknown concrete type server client, given client needs access via known base class interface.

thanks advice,

tim

edit:

as requested hans, here exception message , stack trace.

serializationexception type not resolved member 'server.entityitem,server, version=1.0.0.0,culture=neutral, publickeytoken=null'.  @ interop.serverbase.getentity() @ client.program.main() in c:\users\tim\visual studio .net\solutions\mef testbed\client\program.cs:line 12 @ system.appdomain._nexecuteassembly(runtimeassembly assembly, string[] args) @ system.appdomain.executeassembly(string assemblyfile, evidence assemblysecurity, string[] args) @ microsoft.visualstudio.hostingprocess.hostproc.runusersassembly() @ system.threading.threadhelper.threadstart_context(object state) @ system.threading.executioncontext.run(executioncontext executioncontext, contextcallback callback, object state, boolean ignoresyncctx) @ system.threading.executioncontext.run(executioncontext executioncontext, contextcallback callback, object state) @ system.threading.threadhelper.threadstart() 

i asked related question while back:

would .net remoting relies on tight coupling?


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -