How do you code a Vb.net Remoting Service to listen to more then one TCP channel.
Posted on 2004-11-02
I have a Vb.net Service that I created that I want to be able to listen on multiple ports and have the different ports register to different classes in the same dll. So, for example --- I want port 1 to register to objA.Class1 and port 2 to register to objA.Class2.
This is an example of the code I am using that is located in the onstart method of the service:
TcpNotificationChannel = New TcpServerChannel(1)
RemotingConfiguration.RegisterWellKnownServiceType(GetType(objA.Class1), "Class1", WellKnownObjectMode.SingleCall)
TcpNotificationChannel = New TcpServerChannel(2)
RemotingConfiguration.RegisterWellKnownServiceType(GetType(objA.Class2), "Class2", WellKnownObjectMode.SingleCall)
If I do it this way I receive an error when I try to use the object for port 2. I receive the error "Requested Service not found". But when I use the object using port1 it works just fine. If I switch the order in which they are registered with port 2 being first, the object for port 2 works fine and the call on the object for port 1 fails.
Anyone have any ideas?
Also note -- I plan on moving the registration to a configuration file, but was having problems unregistering the channels when using that approach.