This code throws an ArgumentOutOfRangeException on the last line
var initAddress = IPAddress.Parse("1.65.128.190");
var ipv6Address = initAddress.MapToIPv6();
Assert.IsTrue(ipv6Address.IsIPv4MappedToIPv6);
var ipv4Address = ipv6Address.MapToIPv4();
Can anyone explain why MapToIPv6() and MapToIPv4() are not round trip compatible?
edit: The exception originates from the IPAddress constructor, called by MapToIPv4().
Also, when the first line is
var initAddress = IPAddress.Parse("1.65.128.90");
no exceptions are thrown anymore
edit2: as @Luaan reproduced this, I added the tag [bug-reporting]. Also added [bcl]. Let's see if any MS personnel tracks those tags :)
edit3: reported at Connect https://connect.microsoft.com/VisualStudio/feedback/details/871964
long
,ulong
andint
casts with positive and negative numbers. Why do you want IPv6 mapped IPv4 addresses anyway, though? Are you working with linux servers? I thought Windows doesn't really handle those (since IPv4 and IPv6 are separate drivers on the networking stack - you need two separate sockets to handle both IPv4 and IPv6). – Henn