开发者

Is it possible to hold object instances via C# Remoting?

I'm new to remoting, I want to make a system tray app which will be used to perform some background tasks. I have other 2 programs which need to access the objects modified by the system tray app, and them do stuff with them.

It's more or less like this:

Tray App -> loads everything in background

Program 1 -> Displays some info about "MyObject" instantiated within Tray App

Program 2 -> Utilities for "MyObject" instantiated within Tray App, which connects to a random server elsewhere and do stuff,

But i'm lost on all the remoting concept.

I'm using this:

RemotingConfiguration.RegisterWellKnownService开发者_JS百科Type(commonInterfaceType, Constants.ServiceName, WellKnownObjectMode.Singleton);

But it seems like it's a reference to the object class itself, not an instance of it.

How can I process an Object within an application and let other apps use it? I don't want to use databases, or serialize anything in another file.


To register one of your existing instances and publish it on Remoting do as follows.

First call:

RemotingServices.SetObjecturilForMarshal(MarshalByRefObject, uri)

Then call one of the following overloads:

System.Runtime.Remoting.RemotingServices.Marshal(MarshalByRefObject)
System.Runtime.Remoting.RemotingServices.Marshal(MarshalByRefObject, String)
System.Runtime.Remoting.RemotingServices.Marshal(MarshalByRefObject, String, Type)

That should work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜