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), "FirstRemote",WellKnownObjectMode.SingleCall);
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.
RemotingServices.Marshal(myRemoteClass, "FirstRemote", typeof(MyRemoteClass));
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.