Quiz: How do you expose a .NET object for Remoting?

I've been working on some code to do peer-to-peer communication between .NET applications.
I won't give away all the details in it right now, since my next column will be on
it, but I spent a fair amount of time trying to figure out the answer to this question.

If you look for examples in the doc, you'll find that they do something like:

    RemotingConfiguration.RegisterWellKnownServiceType( typeof(MyRemoteClass),

This code enables somebody connecting to our program and getting a remote instance
of MyRemoteClass. It's not terribly useful, however, since it's a stateless model
- there's no way to get anything back other than a new instance of MyRemoteClass.
What you typically would want is to hook up to an already-existing instance.

So, I started search the RemotingConfiguration class, to see what I could find. The logical thing
to do would be to have something like RegisterInstance, but there's nothing like that
to be found. After about twenty minutes in Google Groups, and I find the answer.


I note this not to show how to do this - though I think this is useful - but to highlight
the problem of letting your developers name the methods in your class. While
"Marshall" may make perfect sense to the class designers, it makes very
little sense to me.  

Comments (3)

  1. Take a look at jabber-net: http://www.jabberstudio.org/projects/jabber-net/project/view.php
    It would then be pretty easy to use Jabber(http://www.jabber.org/) to connect two apps with Logical P2P, rather than Physical P2P.

  2. What about RemotingConfiguration.RegisterActivatedServiceType? It’s in the class RemotingConfiguration, and not that much different to RegisterInstance. It fit’s well to the method you already used: RegisterWellknownServiceType.

Skip to main content