HeatPhoenix
HeatPhoenix

Reputation: 45

Mono on Linux and Missing methods exception

Been trying to program a GTK# app with mono that works on Linux (though GTK# is not directly related to my question).

Now, the problem I've run into is that I'm using the function MapToIPv4() in IPaddress. When targeting Mono 4.5 this function works just fine but when rolling it out to my Linux development environment the function throws

"Missing Method System.Net.IPAddress::MapToIPv4() in assembly /usr/lib/mono/gac/System/4.0.0.0__b77a5c561934e089/System.dll, referenced in assembly myapp.exe"

After a bit of research, I've found out that this is because this function is only in MONO / .NET 4.5 and not 4.0 and seemingly my Linux environment only goes up to 4.0 (because if I target 4.0 it will not compile with this function). (4.5 also does not show up as an installed mono package, though something called "Mono Core library (for CLI 4.5)", does.

How do I get my Linux to allow the usage of this function? Is this even possible? I am using Debian Wheezy (7.8), the mono version I am on is 4.0.1, the latest. If any more information is required, please let me know. Thank you.

Upvotes: 0

Views: 655

Answers (1)

Alexander Köplinger
Alexander Köplinger

Reputation: 2517

First of all to clear up some confusion: Mono's version numbers have no relationship with the .NET version number, i.e. Mono 3.12.0 also shipped the .NET 4.5 profile.

As you found out the MapToIPv4() method is only available in in .NET 4.5 and later (not in .NET 4.0). The exception you're seeing is because Mono hasn't implemented this specific API yet. There's an open pull request for adding it: https://github.com/mono/mono/pull/641.

The only option you have in the meantime is is to implement the conversion yourself in your code.

Upvotes: 0

Related Questions