Server-to-Server Remoting

From: Bob Pulgino (bob_at_digitalmediums.com)
Date: 04/15/04


Date: 15 Apr 2004 02:12:00 -0700

Here's my situation:

I have a classic client/server application that involves multiple
users of a WinForms application connecting to a central remoted .NET
component for business logic and database services. This has been
working fine for a few months now. In fact, it is in production for
two organizations; each organization has its own group of WinForms-app
users and a unique server with the .NET component running to provide
the users within that organization with services for the
organization's unique database.

I am trying to implement a new feature for the next release of this
system that requires the ability to pass information from one
organization's service component to another's; i.e., I need to be able
to call a method on one specific instance of my remoted .NET component
(for organization "A") from within another method of a different
instance (server) of that same component (for organization "B").

My problem is that I can't figure out how to register and instantiate
the proxy for the remote component class from within the local
instance of the same class - when I use the same code I used to
connect from the WinForm application, the framework throws an "Unknown
remoting error" exception the first time I reference the proxy.

Here are the implementation details: I define an abstract base class
called BaseDataService that is used by the client as the interface for
the service component, which is a subclass of BaseDataService called
MaxDataService.

Here is the code I use in the console app that hosts the service
component:

   RemotingConfiguration.Configure("MaxDataServiceConsole.exe.config")

(...from MaxDataServiceConsole.exe.config:)
   <channels>
      <channel ref="http" port="1234">
         <serverProviders>
            <formatter ref="binary" />
         </serverProviders>
      </channel>
   </channels>
   <service>
      <wellknown
         mode="Singleton"
         type="DataServices.MaxDataService, MaxDataService"
         objectUri="MaxDataService.rem"
      />
   </service>

Here is the code I used to connect to the service component from
within the WinForms app:

   Private Shared mDataService As BaseDataService
   ...
   Dim channel As HttpChannel
   channel = New HttpChannel(Nothing, New
BinaryClientFormatterSinkProvider(), Nothing)
   ChannelServices.RegisterChannel(channel)
   Dim serviceUrl as String =
"http://localhost:1234/MaxDataService.rem"
   mDataService = CType(Activator.GetObject(GetType(BaseDataService),
serviceUrl), BaseDataService)

As I said above, this all works fine... the problem arose when I added
a method to the MaxDataService component that used the following code:

      ' Get the URL to the vendor's service component
[1] Dim mdsURL As String =
Me.GetDataServiceURL(soldevent.VendorMemberID)

      ' Obtain connection to the vendor's service component...
[2] Dim mds As MaxDataService = CType(Activator.GetObject( _
         GetType(MaxDataService), mdsURL), MaxDataService)

      ' Test the connection...
[3] Dim test As String = mds.Greetings

Tracing through this code, I know that we have a valid URL after line
[1], and we have a non-null value for 'mds' after line [2] (mds has a
value of type transparentProxy), but when we try to invoke the simple
test member named Greetings in line [3], the "unknown remoting error"
exception is thrown.

Originally, I used the two lines of code shown below right above line
[2]:

   Dim channel As HttpChannel = New HttpChannel(Nothing, New
BinaryClientFormatterSinkProvider(), Nothing)
   ChannelServices.RegisterChannel(channel)

...but I had to remove them because the RegisterChannel call threw an
exception stating that the channel was already registered.

Just out of curiosity, I tried the line of code shown below instead of
line [2] to see what would happen:

   RemotingConfiguration.RegisterWellKnownClientType(GetType(MaxDataService),
mdsURL)

...but this line threw an exception with the following message:

Attempt to redirect activation for type 'DataServices.MaxDataService,
MaxDataService'. This is not allowed since either a well-known
service type has already been registered with that type or that type
has been registered has a activated service type.

I'm assuming my problem is that I'm trying to register a given type as
a remoted type when that type is already known locally (?), but I
can't believe that I'm the only one who ever wanted to do such a thing
- there has to be a way to connect two components of the same type
through .NET remoting (I hope?).

Can anyone help?



Relevant Pages

  • RE: UnregisterChannel Issue in remoting
    ... then registered the remote type: ... When I tried to register the remote ... We need to unregister the remote type after the channel is ... the current problem is how to unregister a remote type. ...
    (microsoft.public.dotnet.distributed_apps)
  • Re: 1st hosting of objects, new(), etc.
    ... > makes sense that New would attempt to create a remote object. ... > application once you have registered a wellknown type in that app domain ... > Register MyObject as a wellknown type ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: HELP - Cant Browse Network Neighborhood in a Domain
    ... my only issue is that remote server isn't showing up in Network ... > The only reasons I can think of for a DC to not register as a browse ... >>> branch and we set up a domain controller down there. ...
    (microsoft.public.windows.server.networking)
  • Registering a Remote Server With Client Tool
    ... A user at a workstation running the Personal Edition (client tools only) ... register using the sa account & password, ... This Windows user was already defined a a valid trusted login in the remote ... remote server, there is a box checked that reads "Allow other SQL Servers to ...
    (microsoft.public.sqlserver.security)
  • Re: 1st hosting of objects, new(), etc.
    ... ASP.Net application dependent on a remote object in a Windows Forms ... > For instance, if my winforms app is the first app to need the object, it> will do a registerWellKnownServerType on a singleton that is also used> locally, and if an IIS application on the same machine runs first, I'll> create a the local object and cache it in the ASP.Net Application object and> then register it. ... > I guess in the case where the hosting app exits, it would cause an exception> on the client, or I could have the process stick around while there are> still non-timed-out clients ...
    (microsoft.public.dotnet.framework.remoting)

Quantcast