all groups > dotnet remoting > april 2008 >
You're in the

dotnet remoting

group:

Multiple Server Objects Sharing a Common URI


Multiple Server Objects Sharing a Common URI Mark Assousa
4/18/2008 6:08:06 PM
dotnet remoting:
I have an assembly (iFormsServer) that exposes two objects descended
from MarshallByRefObject (iFormClient and iFormInstrument). The server
side configuration is as follows:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.runtime.remoting>
<application>
<channels>
<channel ref="tcp" port="5000"/>
</channels>
<service>
<wellknown type="iFormsServer.iFormClient,iFormsServer"
mode="SingleCall" objectUri="iServer"/>
<wellknown type="iFormsServer.iFormInstrument,iFormsServer"
mode="SingleCall" objectUri="iServer"/>
</service>
</application>
</system.runtime.remoting>
</configuration>

The client using these objects is configured thus:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.runtime.remoting>
<application>
<channels>
<channel ref="tcp" port="0"/>
</channels>
<client>
<wellknown type="iFormsServer.iFormClient,iFormsServer"
url="tcp://localhost:5000/iServer"/>
</client>
<client>
<wellknown type="iFormsServer.iFormInstrument,iFormsServer"
url="tcp://localhost:5000/iServer"/>
</client>
</application>
</system.runtime.remoting>
</configuration>

iFormClient implements interface IClientControl. iFormInstrument
implements interface IInstrumentControl.

On one Vista Ultimate machine, everything works as expected. On another,
presumably identical machine, the following client side code fails:

Public Function CreateClient() As Integer
Dim IClient As IClientControl

IClient = New iFormClient
CreateClient = IClient.Create()

End Function

The error states that the object I'm remoting to implements
IInstrumentControl (NOT IClientControl) as if the second wellknown type
registration has overridden the first. If I change the URI in the
registration for iFormsServer.iFormInstrument (on both client and
server) the problem goes away.

So, long winded way of asking, can server activated components share a
common URI or not? When/Why/etc.

RE: Multiple Server Objects Sharing a Common URI Kevin J. Stricklin
5/15/2008 12:49:01 PM
No, the server activated objects cannot share a URI. You should publish a
unique URI for each object you want to expose to clients. It's through the
URI that Remoting knows which object to instantiate.

Standard practice is to make the URI resemble the object. Consider something
like this:

<service>
<wellknown type="iFormsServer.iFormClient,iFormsServer"
mode="SingleCall" objectUri="iFormClient"/>
<wellknown type="iFormsServer.iFormInstrument,iFormsServer"
mode="SingleCall" objectUri="iFormInstrument"/>
</service>


AddThis Social Bookmark Button