Using .Net remote access with ipv6

I am using Activator.CreateInstance(type, "http://localhost/blah")

to call a service using remote access in .Net 3.5 on Windows 7.

As far as I understand, Windows 7 will use IPv6 by default (of course if I ping localhost it resolves as :: 1), so I would expect this URL to make an IPv6 connection, but in my tests it always connects as IPv4

How do I specify in the remote url that I want to use IPv6?

+3


source to share


1 answer


This is because the .net dial-up server listens on IPv4 by default. If your network is configured to use both IPv6 and IPv4, Windows 7 will first resolve the hostname as IPv6 and then as IPv4, which is the default address on which the remote access server listens.

So, in order to use an IPv6 url, you must configure the remote server to listen on IPv6 as well. If you are using app.config do the following:

<system.runtime.remoting>
  <application>
    <service>
      <wellknown mode="Singleton" type="MyApplication.MyServer, MyAssembly" objectUri="MyServer" />
    </service>
    <channels>
      <channel ref="tcp" name="tcp6" port="9000" bindTo="[::]" />
      <channel ref="tcp" name="tcp4" port="9000" bindTo="0.0.0.0" />
    </channels>
  </application>
</system.runtime.remoting>

      



Or configure programmatically:

IDictionary properties = new Hashtable();
properties["name"] = "tcp6";
properties["port"] = 9000;
properties["bindTo"] = "[::]";
TcpServerChannel channel = new TcpServerChannel(properties, null);
ChannelServices.RegisterChannel(channel,  false);

      

See this blog post for details .

+1


source







All Articles