Author Topic: TypeLoadException on linux debian  (Read 5169 times)

meganuke

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 33
    • View Profile
TypeLoadException on linux debian
« on: June 19, 2014, 10:52:11 AM »
hi!!
im trying to run the tnserver on linux and i got this error:

----------

#mono TNServer.exe -name "test" -tcpLobby 5129

Unhandled Exception: System.TypeLoadException: A type load exception has occurred.
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: A type load exception has occurred.
------------

i understand that this is some mono error, but... what can i do?

one thing that i noted is that it seems to be using mono 2.0 instead of 4.0.

could that be the problem?

how can i make it use mono 4?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TypeLoadException on linux debian
« Reply #1 on: June 19, 2014, 07:20:47 PM »
Unfortunately that error message doesn't tell me much and I haven't heard of this before. I can't say much.

meganuke

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 33
    • View Profile
Re: TypeLoadException on linux debian
« Reply #2 on: June 19, 2014, 08:35:41 PM »
i uninstaled mono 2.0 and i got this:

# mono TNServer.exe -name "test" -tcpLobby 5129
The assembly mscorlib.dll was not found or could not be loaded.
It should have been installed in the `/usr/lib/mono/2.0/mscorlib.dll' directory.


why is it looking for mono 2.0?
mono 4 is installed

im using latest version
i bought the license on the asset store a few days ago,

meganuke

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 33
    • View Profile
Re: TypeLoadException on linux debian
« Reply #3 on: June 19, 2014, 11:01:17 PM »
well

i went into the source code, and changed the main function into the ServerMain.cs file

like this:

  1.         static int Main (string[] args)
  2.         {
  3.         try
  4.         {
  5.             if (args == null || args.Length == 0)
  6.             {
  7.                 Console.WriteLine("No arguments specified, assuming default values.");
  8.                 Console.WriteLine("In the future you can specify your own ports like so:\n");
  9.                 Console.WriteLine("   -name \"Your Server\"         <-- Name your server");
  10.                 Console.WriteLine("   -tcp [port]                 <-- TCP port for clients to connect to");
  11.                 Console.WriteLine("   -udp [port]                 <-- UDP port used for communication");
  12.                 Console.WriteLine("   -udpLobby [address] [port]  <-- Start or connect to a UDP lobby");
  13.                 Console.WriteLine("   -tcpLobby [address] [port]  <-- Start or connect to a TCP lobby");
  14.                 Console.WriteLine("   -ip [ip]                    <-- Choose a specific network interface");
  15.                 Console.WriteLine("\nFor example:");
  16.                 Console.WriteLine("  TNServer -name \"My Server\" -tcp 5127 -udp 5128 -udpLobby 5129");
  17.  
  18.                 args = new string[] { "TNet Server", "-tcp", "5127", "-udp", "5128", "-udpLobby", "5129" };
  19.             }
  20.  
  21.             string name = "TNet Server";
  22.             int tcpPort = 0;
  23.             int udpPort = 0;
  24.             string lobbyAddress = null;
  25.             int lobbyPort = 0;
  26.             bool tcpLobby = false;
  27.  
  28.             for (int i = 0; i < args.Length; )
  29.             {
  30.                 string param = args[i];
  31.                 string val0 = (i + 1 < args.Length) ? args[i + 1] : null;
  32.                 string val1 = (i + 2 < args.Length) ? args[i + 2] : null;
  33.  
  34.                 if (val0 != null && val0.StartsWith("-"))
  35.                 {
  36.                     val0 = null;
  37.                     val1 = null;
  38.                 }
  39.                 else if (val1 != null && val1.StartsWith("-"))
  40.                 {
  41.                     val1 = null;
  42.                 }
  43.  
  44.                 if (param == "-name")
  45.                 {
  46.                     if (val0 != null) name = val0;
  47.                 }
  48.                 else if (param == "-tcp")
  49.                 {
  50.                     if (val0 != null) int.TryParse(val0, out tcpPort);
  51.                 }
  52.                 else if (param == "-udp")
  53.                 {
  54.                     if (val0 != null) int.TryParse(val0, out udpPort);
  55.                 }
  56.                 else if (param == "-ip")
  57.                 {
  58.                     if (val0 != null) UdpProtocol.defaultNetworkInterface = Tools.ResolveAddress(val0);
  59.                 }
  60.                 else if (param == "-tcpLobby")
  61.                 {
  62.                     if (val1 != null)
  63.                     {
  64.                         lobbyAddress = val0;
  65.                         int.TryParse(val1, out lobbyPort);
  66.                     }
  67.                     else int.TryParse(val0, out lobbyPort);
  68.                     tcpLobby = true;
  69.                 }
  70.                 else if (param == "-udpLobby")
  71.                 {
  72.                     if (val1 != null)
  73.                     {
  74.                         lobbyAddress = val0;
  75.                         int.TryParse(val1, out lobbyPort);
  76.                     }
  77.                     else int.TryParse(val0, out lobbyPort);
  78.                     tcpLobby = false;
  79.                 }
  80.                 else if (param == "-lobby")
  81.                 {
  82.                     if (val0 != null) lobbyAddress = val0;
  83.                 }
  84.  
  85.                 if (val1 != null) i += 3;
  86.                 else if (val0 != null) i += 2;
  87.                 else ++i;
  88.             }
  89.  
  90.             Start(name, tcpPort, udpPort, lobbyAddress, lobbyPort, tcpLobby);
  91.            
  92.         }
  93.         catch (TypeLoadException e)
  94.         {
  95.            Console.WriteLine(e.ToString());
  96.         }
  97.         return 0;
  98.         }

(if you are lazy to read, i just put everyting into a try / catch block)

and it worked!!...

dont ask me...

lets wait for the support to know if the have an idea

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TypeLoadException on linux debian
« Reply #4 on: June 21, 2014, 05:23:26 PM »
I don't actually see a try/catch block in the code you pasted.

djray2k

  • Jr. Member
  • **
  • Thank You
  • -Given: 4
  • -Receive: 4
  • Posts: 74
  • Blockey Hockey!
    • View Profile
    • Walking Talking Grilling Bear Studios
Re: TypeLoadException on linux debian
« Reply #5 on: June 21, 2014, 06:53:14 PM »
You sure? I see it. Maybe he changed it later.


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TypeLoadException on linux debian
« Reply #6 on: June 21, 2014, 07:34:17 PM »
Or maybe I'm just blind. :) I see it now.

meganuke

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 33
    • View Profile
Re: TypeLoadException on linux debian
« Reply #7 on: June 25, 2014, 01:59:37 AM »
i updated to latest version of tnet server, and now not even with the try / catch is working


can i get some help here please :(

meganuke

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 33
    • View Profile
Re: TypeLoadException on linux debian
« Reply #8 on: June 25, 2014, 02:24:52 AM »
ok found the problem.

it seems it has nothing to do with the try / catch block, hehe.


in order for this to work on linux it has to be compiled to use explicityly .net 4.0

may be the guy who tested it, has a newer version of visual studio, but im usiing visual studio 2010 (and i assume so does the guy who compiled this) and by default it compiles for .net 3.5



you should add this to the documentation!!!!

thanks :D

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TypeLoadException on linux debian
« Reply #9 on: June 25, 2014, 08:05:31 AM »
I do indeed use Visual Studio 2010.