C# binary issue

View: New views
10 Messages — Rating Filter:   Alert me  

C# binary issue

by Cere :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

First of all i want to apologise if this is not the right list to post this. I am a system administrator trying to run a C# binary on Linux as to avoid a windows (server) instalation.

Here is the error i get:

Unhandled Exception: System.FormatException: Input string was not in the correct format
  at System.Int16.Parse (System.String s) [0x00014] in /builddir/build/BUILD/mono-2.4/mcs/class/corlib/System/Int16.cs:212
  at System.Convert.ToInt16 (System.String value) [0x00008] in /builddir/build/BUILD/mono-2.4/mcs/class/corlib/System/Convert.cs:1102
  at gameClass.Game.initRooms () [0x00000]
  at gameClass.Game.initEngine () [0x00000]
  at ChatServer.AppMain.Main (System.String[] args) [0x00000]

I have the same problem whether I am runnning mono 2.4 on Fedora 11 or 1.2 on CentOS 5.2. (in both cases i used the rpms yum provides). libgdiplus is installed.
I am not a programmer so i don't know where to begin in tackling this issue. Any sugestion would be gladly appreciated.

Thank you,

Re: C# binary issue

by Chris Howie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Jun 24, 2009 at 9:05 AM, Cere<cere.mail@...> wrote:

> Hello,
>
> First of all i want to apologise if this is not the right list to post this.
> I am a system administrator trying to run a C# binary on Linux as to avoid a
> windows (server) instalation.
>
> Here is the error i get:
>
> Unhandled Exception: System.FormatException: Input string was not in the
> correct format
>  at System.Int16.Parse (System.String s) [0x00014] in
> /builddir/build/BUILD/mono-2.4/mcs/class/corlib/System/Int16.cs:212
>  at System.Convert.ToInt16 (System.String value) [0x00008] in
> /builddir/build/BUILD/mono-2.4/mcs/class/corlib/System/Convert.cs:1102
>  at gameClass.Game.initRooms () [0x00000]
>  at gameClass.Game.initEngine () [0x00000]
>  at ChatServer.AppMain.Main (System.String[] args) [0x00000]
>
> I have the same problem whether I am runnning mono 2.4 on Fedora 11 or 1.2
> on CentOS 5.2. (in both cases i used the rpms yum provides). libgdiplus is
> installed.
> I am not a programmer so i don't know where to begin in tackling this issue.
> Any sugestion would be gladly appreciated.

It sounds like a bug in the application you are trying to run.  The
exception occurs because a string cannot be parsed into a 16-bit
signed number.

--
Chris Howie
http://www.chrishowie.com
http://en.wikipedia.org/wiki/User:Crazycomputers
_______________________________________________
Gtk-sharp-list maillist  -  Gtk-sharp-list@...
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list

Re: C# binary issue

by Cere :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello and thank you for the answer.



I had a talk with the apps' developer. He made 2 good points:

1. I works on windows.
2. That is macromedia flash' way of outputing stuff and it has to be converted into signed int from string.

So, is there any way i could deploy this app with mono?

Re: C# binary issue

by Stifu :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

It's a closed-source program, right?

It would help to know what string(s) passed to the method cause this exception. I guess Mono is more strict than .NET when converting a string to int. If you don't have access to the program sources, it would be nice if the app author could help (if he can't check with Mono himself, he could just give you a list of examples of the strings converted).

Cere wrote:
Hello and thank you for the answer.



I had a talk with the apps' developer. He made 2 good points:

1. I works on windows.
2. That is macromedia flash' way of outputing stuff and it has to be converted into signed int from string.

So, is there any way i could deploy this app with mono?

Re: C# binary issue

by Cere :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I do have access to the source code but i do now know what to look for. I can provide snips from the code if someone would give me a hint as to what to look for.


Stifu wrote:
It's a closed-source program, right?

It would help to know what string(s) passed to the method cause this exception. I guess Mono is more strict than .NET when converting a string to int. If you don't have access to the program sources, it would be nice if the app author could help (if he can't check with Mono himself, he could just give you a list of examples of the strings converted).

Re: C# binary issue

by Stifu :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Here's what I'd do (feel free to ask a programmer for help if you struggle):

1- Open the source code in an IDE that supports debugging (Visual Studio or SharpDevelop on Windows, MonoDevelop on Linux)
2- Go to the gameClass.Game.initRooms () method, and look where it converts a string to int
3a- If you're debugging with .NET, put a break point right before the conversion, and note down the string value (assuming the exception is always triggered... you could also note down several passed string values just in case).
3b- If you're debugging with Mono, run the app in debug mode, make the exception occur, then note down the string value that caused this.

If you can hand out the sources (or if they are public), I don't mind doing it myself. It shouldn't be much work.


Hello,

I do have access to the source code but i do now know what to look for. I can provide snips from the code if someone would give me a hint as to what to look for.


Stifu wrote:
It's a closed-source program, right?

It would help to know what string(s) passed to the method cause this exception. I guess Mono is more strict than .NET when converting a string to int. If you don't have access to the program sources, it would be nice if the app author could help (if he can't check with Mono himself, he could just give you a list of examples of the strings converted).


Re: C# binary issue

by Cere :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

My monodevelop doens't have any option to insert a watch/breackpoint/whatever so i'm stuck with mdb. I have the following code:

" 230                     addRoom(i - 1, ids[i - 1], numes[i - 1], Convert.ToInt32(maxPlayers[i - 1]), Convert.ToInt32(sb[i - 1]), Convert.ToInt32(bb[i - 1]), Convert.ToInt32(minBuy[i - 1]), Convert.ToInt32(maxBuy[i - 1]));                                                                                                                                                                                                
(mdb) list                                                                                                                                                                                                    
 229                 {                                                                                                                                                                                        
 230                     addRoom(i - 1, ids[i - 1], numes[i - 1], Convert.ToInt32(maxPlayers[i - 1]), Convert.ToInt32(sb[i - 1]), Convert.ToInt32(bb[i - 1]), Convert.ToInt32(minBuy[i - 1]), Convert.ToInt32(maxBuy[i - 1]));                                                                                                                                                                                                
 231                 }                                                                                                                                                                                        
 232                 Console.WriteLine(nrRooms + " rooms created...");                                                                                                                                        
 233             }                                                                                                                                                                                            
 234             else                                                                                                                                                                                          
 235             {                                                                                                                                                                                            
 236                 Console.WriteLine("rooms failed to create");                                                                                                                                              
 237             }                                                                                                                                                                                            
 238             Console.WriteLine("checking gifts info...");                                                                                                                                                  
 239             buf = viewPhp(getGiftsInfo);                                                                                                                                                                  
 240                                                                                                                                                                                                          
 241             if (buf != "")
 242             {
 243                 string[] arr = buf.Split(delimit1);
 244                 string[] names = arr[0].Split(delimit2);
 245                 string[] prices = arr[1].Split(delimit2);
 246
 247                 for (int i=1;i<=prices.Length;i++)
 248                 {
"
I want to print the output of  Convert.ToInt32(maxPlayers[i - 1]) but the program exits

  at System.Int32.Parse (System.String s) [0x00014] in /builddir/build/BUILD/mono-2.4/mcs/class/corlib/System/Int32.cs:588
  at System.Convert.ToInt32 (System.String value) [0x00008] in /builddir/build/BUILD/mono-2.4/mcs/class/corlib/System/Convert.cs:1254
  at gameClass.Game.initRooms () [0x00122] in /home/cere/temp/poker/Server/gameEngine.cs:230
  at gameClass.Game.initEngine () [0x0005a] in /home/cere/temp/poker/Server/gameEngine.cs:270
  at ChatServer.AppMain.Main (System.String[] args) [0x000c7] in /home/cere/temp/poker/Server/Program.cs:45
Thread @34 exited with exit code 1.
Thread @34 exited.

I couldn't print it before execution:
(mdb) print Convert.ToInt32(maxPlayers[0])
ERROR: Invocation of `Convert.ToInt32 ()' raised an exception: Class `System.Convert' not initialized yet.



Stifu wrote:
Here's what I'd do (feel free to ask a programmer for help if you struggle):

1- Open the source code in an IDE that supports debugging (Visual Studio or SharpDevelop on Windows, MonoDevelop on Linux)
2- Go to the gameClass.Game.initRooms () method, and look where it converts a string to int
3a- If you're debugging with .NET, put a break point right before the conversion, and note down the string value (assuming the exception is always triggered... you could also note down several passed string values just in case).
3b- If you're debugging with Mono, run the app in debug mode, make the exception occur, then note down the string value that caused this.


Re: C# binary issue

by Stifu :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hmmm... Int32? The exception you pasted in your first post mentioned Int16. Could the exception possibly be due to some kind of 16/32 confusion?

"I want to print the output of  Convert.ToInt32(maxPlayers[i - 1]) but the program exits"

That's to be expected. You shouldn't try to print this, but just maxPlayers[i - 1] alone instead.


Hello,

My monodevelop doens't have any option to insert a watch/breackpoint/whatever so i'm stuck with mdb. I have the following code:

" 230                     addRoom(i - 1, ids[i - 1], numes[i - 1], Convert.ToInt32(maxPlayers[i - 1]), Convert.ToInt32(sb[i - 1]), Convert.ToInt32(bb[i - 1]), Convert.ToInt32(minBuy[i - 1]), Convert.ToInt32(maxBuy[i - 1]));                                                                                                                                                                                                
(mdb) list                                                                                                                                                                                                    
 229                 {                                                                                                                                                                                        
 230                     addRoom(i - 1, ids[i - 1], numes[i - 1], Convert.ToInt32(maxPlayers[i - 1]), Convert.ToInt32(sb[i - 1]), Convert.ToInt32(bb[i - 1]), Convert.ToInt32(minBuy[i - 1]), Convert.ToInt32(maxBuy[i - 1]));                                                                                                                                                                                                
 231                 }                                                                                                                                                                                        
 232                 Console.WriteLine(nrRooms + " rooms created...");                                                                                                                                        
 233             }                                                                                                                                                                                            
 234             else                                                                                                                                                                                          
 235             {                                                                                                                                                                                            
 236                 Console.WriteLine("rooms failed to create");                                                                                                                                              
 237             }                                                                                                                                                                                            
 238             Console.WriteLine("checking gifts info...");                                                                                                                                                  
 239             buf = viewPhp(getGiftsInfo);                                                                                                                                                                  
 240                                                                                                                                                                                                          
 241             if (buf != "")
 242             {
 243                 string[] arr = buf.Split(delimit1);
 244                 string[] names = arr[0].Split(delimit2);
 245                 string[] prices = arr[1].Split(delimit2);
 246
 247                 for (int i=1;i<=prices.Length;i++)
 248                 {
"
I want to print the output of  Convert.ToInt32(maxPlayers[i - 1]) but the program exits

  at System.Int32.Parse (System.String s) [0x00014] in /builddir/build/BUILD/mono-2.4/mcs/class/corlib/System/Int32.cs:588
  at System.Convert.ToInt32 (System.String value) [0x00008] in /builddir/build/BUILD/mono-2.4/mcs/class/corlib/System/Convert.cs:1254
  at gameClass.Game.initRooms () [0x00122] in /home/cere/temp/poker/Server/gameEngine.cs:230
  at gameClass.Game.initEngine () [0x0005a] in /home/cere/temp/poker/Server/gameEngine.cs:270
  at ChatServer.AppMain.Main (System.String[] args) [0x000c7] in /home/cere/temp/poker/Server/Program.cs:45
Thread @34 exited with exit code 1.
Thread @34 exited.

I couldn't print it before execution:
(mdb) print Convert.ToInt32(maxPlayers[0])
ERROR: Invocation of `Convert.ToInt32 ()' raised an exception: Class `System.Convert' not initialized yet.



Stifu wrote:
Here's what I'd do (feel free to ask a programmer for help if you struggle):

1- Open the source code in an IDE that supports debugging (Visual Studio or SharpDevelop on Windows, MonoDevelop on Linux)
2- Go to the gameClass.Game.initRooms () method, and look where it converts a string to int
3a- If you're debugging with .NET, put a break point right before the conversion, and note down the string value (assuming the exception is always triggered... you could also note down several passed string values just in case).
3b- If you're debugging with Mono, run the app in debug mode, make the exception occur, then note down the string value that caused this.



Re: C# binary issue

by Cere :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

It's an emply string as far as i can see:


Thread @35 stopped at #0: 0xb6f8b3c0 in gameClass.Game.initRooms()+0x4f0 at /home/cere/temp/poker/Server/gameEngine.cs:230.
 230                     addRoom(i - 1, ids[i - 1], numes[i - 1], Convert.ToInt32(maxPlayers[i - 1]), Convert.ToInt32(sb[i - 1]), Convert.ToInt32(bb[i - 1]), Convert.ToInt32(minBuy[i - 1]), Convert.ToInt32(maxBuy[i - 1]));
Display 1 ("18"): 18
(mdb) print sb[0]
(string) ""
(mdb) print sb[1]
ERROR: Index of array expression `sb' out of bounds.
(mdb) print i
(int) 1
(mdb) print bb[0]
(string) ""
(mdb) print bb[1]
ERROR: Index of array expression `bb' out of bounds.
(mdb) print minBuy[1]
ERROR: Index of array expression `minBuy' out of bounds.
(mdb) print minBuy[0]
(string) ""

Re: C# binary issue

by Stifu :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I just tried, and doing Convert.ToInt32(string.Empty); or Convert.ToInt32(""); throws an exception with .NET. Convert.ToInt32(null); works with both .NET and Mono, though.
So that's not what's happening in the program (ie: the string is not empty), or it'd fail with .NET too...

We could spend ages trying to blindly debug this. Can't you privately give me the sources so I can have a look?

Cere wrote:
It's an emply string as far as i can see:


Thread @35 stopped at #0: 0xb6f8b3c0 in gameClass.Game.initRooms()+0x4f0 at /home/cere/temp/poker/Server/gameEngine.cs:230.
 230                     addRoom(i - 1, ids[i - 1], numes[i - 1], Convert.ToInt32(maxPlayers[i - 1]), Convert.ToInt32(sb[i - 1]), Convert.ToInt32(bb[i - 1]), Convert.ToInt32(minBuy[i - 1]), Convert.ToInt32(maxBuy[i - 1]));
Display 1 ("18"): 18
(mdb) print sb[0]
(string) ""
(mdb) print sb[1]
ERROR: Index of array expression `sb' out of bounds.
(mdb) print i
(int) 1
(mdb) print bb[0]
(string) ""
(mdb) print bb[1]
ERROR: Index of array expression `bb' out of bounds.
(mdb) print minBuy[1]
ERROR: Index of array expression `minBuy' out of bounds.
(mdb) print minBuy[0]
(string) ""