lidgren / lidgren-network-gen3

Lidgren Network Library
https://groups.google.com/forum/#!forum/lidgren-network-gen3
MIT License
1.19k stars 331 forks source link

Unable to run compiled application on linux #61

Open DebugDax opened 8 years ago

DebugDax commented 8 years ago

Hello,

I have attempted to get a compiled server executable to run on linux but I keep getting Unhandled Exceptions. I am compiling in VS2013/VS2015 on Win8.1x64

I have not been able to get even the included samples to run on my Debian 8 box, executing for instance the "EncryptionSample/EncryptionServer.exe" I get the following:

Unhandled Exception:
System.NotImplementedException: The method or operation is not implemented.
at System.Net.NetworkInformation.NetworkInterfaceFactory+LinuxNetworkInterfaceAPI.GetNetMask (System.Net.IPAddress address) <0x41c958b0 + 0x00017> in <filename unknown>:0
at System.Net.NetworkInformation.NetworkInterface.GetNetMask (System.Net.IPAddress address) <0x41c95880 + 0x0001c> in <filename unknown>:0
at System.Net.NetworkInformation.LinuxUnicastIPAddressInformation.get_IPv4Mask () <0x41c957d0 + 0x00043> in <filename unknown>:0
at Lidgren.Network.NetUtility.GetBroadcastAddress () <0x41c6d870 + 0x000f6> in <filename unknown>:0
at Lidgren.Network.NetPeerConfiguration..ctor (System.String appIdentifier) <0x41c6d4d0 + 0x0015b> in <filename unknown>:0
at EncryptionServer.Program.Main (System.String[] args) <0x41c6ad50 + 0x0004f> in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.NotImplementedException: The method or operation is not implemented.
at System.Net.NetworkInformation.NetworkInterfaceFactory+LinuxNetworkInterfaceAPI.GetNetMask (System.Net.IPAddress address) <0x41c958b0 + 0x00017> in <filename unknown>:0
at System.Net.NetworkInformation.NetworkInterface.GetNetMask (System.Net.IPAddress address) <0x41c95880 + 0x0001c> in <filename unknown>:0
at System.Net.NetworkInformation.LinuxUnicastIPAddressInformation.get_IPv4Mask () <0x41c957d0 + 0x00043> in <filename unknown>:0
at Lidgren.Network.NetUtility.GetBroadcastAddress () <0x41c6d870 + 0x000f6> in <filename unknown>:0
at Lidgren.Network.NetPeerConfiguration..ctor (System.String appIdentifier) <0x41c6d4d0 + 0x0015b> in <filename unknown>:0
at EncryptionServer.Program.Main (System.String[] args) <0x41c6ad50 + 0x0004f> in <filename unknown>:0

I saw another issue posting here that stated to include __CONSTRAINED__ in the defined symbols field, which causes the compiler to use PlatformConstrained.cs instead of PlatformWin32.cs, when applying this change my error changes to:

Unhandled Exception:
System.TypeInitializationException: The type initializer for 'Lidgren.Network.NetRandom' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Lidgren.Network.MWCRandom' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Lidgren.Network.NetUtility' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object
at Lidgren.Network.NetUtility..cctor () <0x4080ea90 + 0x00085> in <filename unknown>:0
--- End of inner exception stack trace ---
at Lidgren.Network.NetRandomSeed.GetUInt64 () <0x4080b230 + 0x000f7> in <filename unknown>:0
at Lidgren.Network.NetRandomSeed.GetUInt32 () <0x4080b1f0 + 0x0000b> in <filename unknown>:0
at Lidgren.Network.NetRandom..ctor () <0x4080afc0 + 0x0001f> in <filename unknown>:0
at Lidgren.Network.MWCRandom..ctor () <0x4080af30 + 0x0000f> in <filename unknown>:0
at Lidgren.Network.MWCRandom..cctor () <0x4080af80 + 0x00027> in <filename unknown>:0
--- End of inner exception stack trace ---
at Lidgren.Network.NetRandom..cctor () <0x4080ad50 + 0x00027> in <filename unknown>:0
--- End of inner exception stack trace ---
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'Lidgren.Network.NetRandom' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Lidgren.Network.MWCRandom' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Lidgren.Network.NetUtility' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object
at Lidgren.Network.NetUtility..cctor () <0x4080ea90 + 0x00085> in <filename unknown>:0
--- End of inner exception stack trace ---
at Lidgren.Network.NetRandomSeed.GetUInt64 () <0x4080b230 + 0x000f7> in <filename unknown>:0
at Lidgren.Network.NetRandomSeed.GetUInt32 () <0x4080b1f0 + 0x0000b> in <filename unknown>:0
at Lidgren.Network.NetRandom..ctor () <0x4080afc0 + 0x0001f> in <filename unknown>:0
at Lidgren.Network.MWCRandom..ctor () <0x4080af30 + 0x0000f> in <filename unknown>:0
at Lidgren.Network.MWCRandom..cctor () <0x4080af80 + 0x00027> in <filename unknown>:0
--- End of inner exception stack trace ---
at Lidgren.Network.NetRandom..cctor () <0x4080ad50 + 0x00027> in <filename unknown>:0
--- End of inner exception stack trace ---

I see it mentioning MWCRandom inside NetRandom, the only line I can find referencing that is: public static NetRandom Instance = new MWCRandom();

I'm unsure how to proceed further as my internet research does not pull up much on the way of MWC.

Leaving out __CONSTRAINED__, I am able to run the executables in Windows without any issue. I am using the mono-complete package v4.2.1 on my linux box.

Any help is appreciated, Thanks.

Trojaner commented 8 years ago

The first exception is from mono, it doesn't support GetNetMask() in the version you are using. Update maybe?

nyon commented 7 years ago

Had the same problem. Upgraded from mono 4.2.1 to 5.0.1.1. Problem is fixed then.