Bug 51557 - IPAddress.MapToIPv4/MapToIPv6 does not working
Summary: IPAddress.MapToIPv4/MapToIPv6 does not working
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System (show other bugs)
Version: 4.6.0 (C8)
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-01-16 16:41 UTC by alexvaluyskiy
Modified: 2017-09-01 11:33 UTC (History)
2 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description alexvaluyskiy 2017-01-16 16:41:52 UTC
I've tried to run this code on Mono/Linux
> static void Main(string[] args)
> {
>   IPAddress address = IPAddress.Parse("128.50.24.12");
>   var newAddressIPv4 = address.MapToIPv4();
>   var newAddressIPv6 = address.MapToIPv6();
> }

but I've got an error

> Program.cs(15,42): error CS1061: Type `System.Net.IPAddress' does not contain a definition for `MapToIPv4' and no extension method `MapToIPv4' of type `System.Net.IPAddress' could be found. Are you missing an assembly reference? /usr/lib/mono/4.5-api/System.dll (Location of the symbol related to previous error)
> Program.cs(16,42): error CS1061: Type `System.Net.IPAddress' does not contain a definition for `MapToIPv6' and no extension method `MapToIPv6' of type `System.Net.IPAddress' could be found. Are you missing an assembly reference? /usr/lib/mono/4.5-api/System.dll (Location of the symbol related to previous error)

It's weird, because I've found these extensions methods in the source code here
https://github.com/mono/mono/blob/master/mcs/class/referencesource/System/net/System/Net/IPAddress.cs#L753
Comment 1 Marek Safar 2017-01-16 20:58:11 UTC
We are probably missing this API in our 4.5 compatibility files. Targeting .net 4.6 should workaround/fix this problem
Comment 2 alexvaluyskiy 2017-01-17 07:26:46 UTC
I've checked it in 4.6 project and it's works. But these APIs become available since .NET 4.5

Note You need to log in before you can comment on or make changes to this bug.