c# - RemotingServices.Marshal() does not work when invoked from another AppDomain -


i trying setup object remoting server. use remotingservices.marshal(myobj, uri) this. have following piece of code:

public class ipcremoteobject : marshalbyrefobject {     public void register()     {         var channel = new ipcchannel("ipcsample");         channelservices.registerchannel(channel, false);         remotingservices.marshal(this, "test", typeof(ipcremoteobject));         console.writeline("created server, waiting calls");         console.readline();     } } 

if call main() of program below, works:

// case 1: works new ipcremoteobject().register(); 

however, if create object in appdomain below, "remotingexception: requested service not found" when connecting clients.

// case 2: completes without error, client connections fail var appdomain = appdomain.createdomain("foo"); var remoteobj = (ipcremoteobject)appdomain.createinstanceandunwrap(assembly, typename); remoteobj.register(); 

then, if create intermediate class makes call register() on behalf , instantiate class in appdomain, normal:

// case 3: works class bootstrapper : marshalbyrefobject {     public void register()     {          new ipcremoteobject().register();     } } ... var appdomain = appdomain.createdomain("foo"); var bootstrapper = (bootstrapper)appdomain.createinstanceandunwrap(                                           bootstrapperassembly, bootstrappertype); bootstrapper.register(); // works 

so, here's question: why remotingservices.marshal() not work in case 2? there kind of rule, or bug in remoting? using .net framework 4.5.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -