all groups > dotnet remoting > september 2007 >
You're in the

dotnet remoting

group:

Passing MarshalByRef object to Remoted Server



Passing MarshalByRef object to Remoted Server sbparsons
9/5/2007 9:28:05 AM
dotnet remoting: Please could someone let me know if this is possible:

I have a server object exposed through remoting on one PC and a client
object that gets a proxy to this server object.

The client object configures and registers a channel as per:

System.Collections.IDictionary properties;
properties = new System.Collections.Hashtable();
properties["name"] = "client";
properties["priority"] = "1";
properties["port"] = 0;
ChannelServices.RegisterChannel(new TcpChannel(properties,
null, null), false);

Once a connection has been made, the client calls the following on the
server proxy:
_remoteMaster.ConnectToLibrary((IClient)this)

The IClient interface exists on both machines.

During debugging I can step through to the above line and into it - and then
on the remote server, I can step through the ConnectToLibrary function and
all is well until...

As soon as I attempt to reference a property on the IClient object I get the
following error:
"Failed to connect to an IPC Port: The system cannot find the file specified."

The strange thing is the IPC reference, as I am using TCP.
Though this scenario did work while I had both master and client on the same
machine (though not referencing each other).

I hope that this scenario is clear. Looking forward to a bit of help on this
RE: Passing MarshalByRef object to Remoted Server sbparsons
9/5/2007 9:48:00 AM
Right - I found the problem so please disregard the original post.

I had an IPC channel configured in the Client config file and as soon as I
commented that out my object was available on the server.

I wonder if it's then possible to mix IPC with TCP in this scenario - I was
planning on using IPC between the client and a GUI but it looks as though TCP
will have to stick.

[quoted text, click to view]
Re: Passing MarshalByRef object to Remoted Server sbparsons
9/6/2007 8:24:02 AM
Hi Ged,

No - I was intending to use TCP all the way through, from Client to Server
as the objects are on different machines. However, purely because of the fact
that I had an IPC channel configured in the Client's config file, when it
came to passing a MarshalByRef instance of the Client to the remoted Server
Proxy interface, the channel that the Client proxy was listening on happened
to be IPC.

So - when the server attempted to invoke a method on the Client proxy it
failed with the IPC error as per above.
As soon as I removed the IPC channel from the config file, the Client proxy
was passed to the server and was then using TCP (which worked).

My final question was - I was hoping to hook a local GUI to the Client via
IPC but it now looks as though TCP will have to be used (actually, am using
it at the moment).

Regards,
Sean

[quoted text, click to view]
Re: Passing MarshalByRef object to Remoted Server <Ged>
9/6/2007 11:57:20 AM
Hi sbparsons

If I understand you, what you are trying to do it get the client to use IPC
to talk to the server, which is using TCP?
If so, then no. You can't do that.

If you want your client to talk to different end points, using different
channels, then that is possible.
Also, you can use WCF (part of .NET 3.0) to have your server listen on
different channels.
i.e. The client talks to the server using TCP, but the GUI talks to the
server using IPC.

HTH

--
Ged Moretta
Senior Software Engineer
AppSense Ltd
www.appsense.com

-----------------------------------------------------------------------
This signature isn't automatic. I have to type it manually every time.


[quoted text, click to view]
AddThis Social Bookmark Button