I have a remoting server (Class Factory) running on a PC with 2 NICs. NIC 1
is DHCP, NIC 2 is fixed IP Address.
I have clients connecting successfully on NIC 1, but clients connecting to
NIC 2 fail when accessing the methods of the inner classes of the Class
Factory.
For each NIC (IP Address), I create a Server Channel as follows, using a
different channel name for each NIC (IP Address), and binding the channel to
the IPAddress of the NIC:
private void RegisterServerChannel(string name, int port, IPAddress ipAddress)
{
IDictionary props = new Hashtable();
props["name"] = name;
props["port"] = port;
props["bindTo"] = ipAddress.ToString();
props["strictBinding"] = true;
BinaryServerFormatterSinkProvider serverProv =
new BinaryServerFormatterSinkProvider();
serverProv.TypeFilterLevel =
System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
BinaryClientFormatterSinkProvider clientProv =
new BinaryClientFormatterSinkProvider();
HttpChannel chnl = new HttpChannel(props, clientProv, serverProv);
ChannelServices.RegisterChannel(chnl);
}
After each Server Channel is registered, I call:
RemotingServices.Marshal(classFactory, objURI, typeof(IClassFactory));
I have a shared assembly that contains the interfaces for the classes
(simplified):
namespace SharedInterfaces
{
public interface IClassFactory
{
string SomeString{ get; set; }
IInnerClass InnerClass { get; }
}
public interface IInnerClass
{
bool SomeValue { get; }
}
}
When both NICs are enabled (clients connected to NIC 1 work perfectly).
Clients on NIC 2 can connect and successfully call IClassFactory.SomeString,
but when the Client on NIC 2 calls IClassFactory.InnerClass.SomeValue, I get
the following excetion:
System.Net.WebException: The underlying connection was closed: Unable to
connect to the remote server.
Server stack trace:
at System.Net.HttpWebRequest.CheckFinalStatus()
at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult)
at System.Net.HttpWebRequest.GetRequestStream()
at
System.Runtime.Remoting.Channels.Http.HttpClientTransportSink.ProcessAndSend(IMessage msg, ITransportHeaders headers, Stream inputStream)
at
System.Runtime.Remoting.Channels.Http.HttpClientTransportSink.ProcessMessage(IMessage
msg, ITransportHeaders requestHeaders, Stream requestStream,
ITransportHeaders& responseHeaders, Stream& responseStream)
at
System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type)
at SharedInterfaces.IInnerClass.get_SomeValue()
If I disable NIC1, the clients can access the inner classes of the class
factory on NIC 2. With both NIC 1 and NIC 2 enabled, the clients on NIC 2
can access "top level" mehtods of the class factory, but cannot access the
methods referencing the inner classes.
In short, the applicaiton works fine when there is only 1 NIC, but something
is going wrong when using 2 NICs. I suspect that I have something missing in
my configuration, but I am not able to find it.
Any input is greatly appreciated.
Thanks in advance.
--