Bidirectional communications with .NET remoting

From: Matt Kosorok (MattKosorok_at_discussions.microsoft.com)
Date: 12/30/04


Date: Thu, 30 Dec 2004 10:09:01 -0800

I'm getting really close ( thanks to Ken Kolda, you're awesome, dude ).
Here's what I'm trying to do: ( warning, long message here )

I have a remote object that has a public delegate. The host application
uses the following code to publish the remote object:

// serverProvider object
BinaryServerFormatterSinkProvider serverProvider = new
BinaryServerFormatterSinkProvider() ;
// set filter level
serverProvider.TypeFilterLevel =
System.Runtim.Serialization.Formatters.TypeFilterLevel.Full ;
// set up IDictionary
IDictionary props = new Hastable() ;
props["port"] = nMyTcpPort ;

// set up tcp channel
TcpChannel channel = new TcpChannel( props, null, serverProvider ) ;
ChannelServices.RegisterChannel( channel ) ;

// register remote object
ObjRef remoteObject = RemotingServices.Marshal( myRemoteObject, strTitle ) ;

So now I've published my remote object. My client object uses
RemotingServices.Configure( client.config ) ;
and the client.config file looks like this:

<configuration>
 <system.runtime.remoting>
  <application>
   <client>
    <wellknown
     type = "MyObjectType, mydll"
     url = "tcp://localhost:nMyTcpPort/strTitle" />
   </client>
   <channels>
    <channel
     ref = "tcp"
     port = "0" >
     <clientProviders>
      <formatter ref = "binary" />
     </clientProviders>
     <serverProviders>
      <formatter ref = "binary" typeFilterLevel = "Full" />
     </serverProviders>
   </channels>
  </application>
 </system.runtime.remoting>
</configuration>

I also have a listener dll on the client side, and an injector on the server
side. With the client, I register a callback in the remote object that
points to a method in the listener. I also register a callback with the
listener that points to the method I want called in the client. Both the
server-side injector and the client-side client app have a method that
increases a count variable in the remote object.

When I test this, everything connects and communicats correctly with the
remote singleton object. With the injector, I can increase the count
variable of the remote object. With the client, it can also increase it, and
both the injector's and the client's remote object count changes are seen
correctly by both objects. ( i.e., the injector sets the remote object's
count to 1, the client sees it as one, and increases it to 23, and the
injector then sees 23 and so on ).

However, when I use the injector to execute the callback registered in the
remote object, which is supposed to execute the method on the client-side in
the listener.dll, which is then supposed to execute the method in the
client-side client application, I don't actually get anything executed.

My guess is there's something different with how the server-side remote
object is set up programmatically ( versus a config file ), and that my
client-side config file is not appropriately set in the config file.

When I switch the host to provide the exact same remote object using a
config file, I get full communication in both directions, but lose the
ability to terminate the remote host at will ( I have to shut down the
application ).

Here is the server-side config file:

<configuration>
 <system.runtime.remoting>
  <application name = "Host" >
   <service>
    <wellknown
     mode = "Singleton"
     type = "myType, myDll"
     objectUri = "strTitle" />
   </service>
   <channels>
    <channel ref = "tcp" port = myTcpPort>
     <serverProviders>
      <formatter ref = "binary" typeFilterLevel = "Full" />
     </serverProviders>
    </channel>
   </channels>
  </application>
 </system.runtime.remoting>
</configuration>

I'm so close to making this thing work exactly how I want to. I just have
to overcome this last major obstical, and I'll be a very happy man.

-- 
- Matt Kosorok


Relevant Pages

  • Re: Accessing server resources from remotable object
    ... > Your remoting host is on the IIS server, so you can have the remote object ... > write to a physical path. ... > the virtual directory and http. ... > Use a naming convention specific to each client if you are going to expect ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: remoting serialization exception
    ... Is the same remote object being ... >> client and server using slightly different versions of the remote object ... > objectId, BinaryAssemblyInfo assemblyInfo, SizedArray ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: remoting options
    ... client project and add a remote object reference just like they have the ... > apply if you're using IIS to host the server) and the version of the ... > application that you want the server to use. ... > client code somehow so that it can be loaded/instantiated on the client. ...
    (microsoft.public.dotnet.distributed_apps)
  • Re: remoting options
    ... No I did not add a reference to the remote object in my client ... I just copied it into the bin directory on my client. ... > * Create an interface dll for your remote object. ...
    (microsoft.public.dotnet.distributed_apps)
  • Re: remoting options
    ... I also don't know if you can use a configuration file on the client side for a remote object hosted in IIS: although I don't see why not. ... If you were to do this, that config file would *not* be web.config. ... You'll also need a reference to your proxy|interface|abstract base class in your client project references. ... If none of the above makes sense, my advice is to try to create a simple console application client with just enough code in it to prove that it's getting a constructive response from the remote object. ...
    (microsoft.public.dotnet.distributed_apps)