Note that there are some explanatory texts on larger screens.

plurals
  1. PORemotingServices.Marshal() does not work when invoked from another AppDomain
    primarykey
    data
    text
    <p>I am trying to setup my object as remoting server. I use <code>RemotingServices.Marshal(myObj, uri)</code> for this. I have the following piece of code:</p> <pre><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 for calls"); Console.ReadLine(); } } </code></pre> <p>If I call this from Main() of my program like below, everything works:</p> <pre><code>// case 1: works new IpcRemoteObject().Register(); </code></pre> <p>However, if I create the object in another AppDomain like below, I get "RemotingException: Requested Service not found" when connecting from clients.</p> <pre><code>// case 2: completes without error, but client connections fail var appDomain = AppDomain.CreateDomain("foo"); var remoteObj = (IpcRemoteObject)appDomain.CreateInstanceAndUnwrap(assembly, typename); remoteObj.Register(); </code></pre> <p>Then, if I create an intermediate class that makes call to Register() on my behalf and instantiate that class in another appdomain, everything is back to normal:</p> <pre><code>// 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 </code></pre> <p>So, here's the question: why <code>RemotingServices.Marshal()</code> does not work in case 2? Is there some kind of rule, or is it simply a bug in remoting? I am using .NET framework 4.5.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload