Hello all
I have currently come across a strange situation with one of my customers upgrading there machines from Windows XP to Windows 7. On the Windows 7 hosts file a record exist for local host pointing to a non standard IP (NOT 127.0.0.1). From some research I see that Windows 7 uses a DNS service to issue the local host IP, so from a few test I can see a conflict arises. I create a TcpChannel as follows on the server.
BinaryClientFormatterSinkProvider clientProvider = null;
BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider();
serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
IDictionary props = new Hashtable();
props["port"] = 1234;
props["typeFilterLevel"] = TypeFilterLevel.Full;
TcpChannel chan = new TcpChannel(props, clientProvider, serverProvider);
ChannelServices.RegisterChannel(chan, false);
If I do a netstat -a
I see the service is running at 0.0.0.0:1234
My problem comes now trying to access the address of the service.
My client code below
string URL = "tcp://" + "localhost" + ":" + "1234" + "/" + "Link";
Lib = (Server.LinkLibrary)Activator.GetObject(typeof(Server.LinkLibrary),
URL);
My problem now is localhost is resolved from the Windows Hosts file. This means that the server LocalHost and the Reference to localHost are different.
My question is how do I resolve this without hard coding the localhost in the code to
127.0.0.1 and not changing the Windows Hosts file from the non-Standard localhost?
Thanks