.NET     Console.WriteLine( "All Things .NET" );
.NET Nerd Blog Home
6.11.2002

 

Remoting Trials


Finally getting around to trying some remoting of my own. Here are some gotchas that I've run into:

As the examples do it, I have the remotable object in its own assembly. Then the server project is just a simple console app that reads the config file and waits for <enter> key to stop. The client project has a reference to the remotable object, and reads the client config file to setup the remoting. The entries in the client config file caused some confusion...

Client Config

<configuration>
<system.runtime.remoting>
<application>
<client>
<!--
wellknown
type: object, assembly
url: http://machine:port/uri (uri as specified in server config file)
-->

<wellknown
type="RemoteAddrMarshal, RemoteAddrObj"
url="http://localhost:6789/RemServerUri"
/>
</client>
<channels>
<!-- Port 0 allows remoting to choose a channel for return calls.
(May only be necessary if using callbacks to client)
-->
<channel
ref="http"
port="0"
/>
</channels>


Server Config

<configuration>
<system.runtime.remoting>
<application>
<service>
<wellknown
mode="Singleton"
type="RemoteAddrMarshal, RemoteAddrObj"
objectUri="RemServerUri"
/>
</service>
<channels>
<channel
ref="http"
port="6789"
/>
</channels>


Common Problems
  • The underlying connection was closed: Unable to connect to the remote server - server process not started or client connecting on wrong machine/port
  • Object has been disconnected or does not exist at the server - incorrect URI for remote object
  • Cannot load type RemoteAddrMarshal, RemoteAddrObj - server can not load the speicified type. Syntax is "[namespace.]type,assembly" - are you missing a namespace in the type name?


Notes
  • Use RemotingServices.IsTransparentProxy to determine if you have a proxy to MarhsalByRef object or local object.
  • RemotingConfiguration.Configure and new will both succeed even if server not available. Won't get error until the first call to remote object.
  • If remote object is declared within a namespace, be sure to include that namespace in the wellknown / type element in both client and server config files.
  • If remote object is declared serializable, the remote server doesn't have to be running. In my test case, the object is implemented in an assembly separate from the remote object, so the server is unnecessary.



Comments: Post a Comment

Powered by Blogger