« Return to Thread: C# binary issue

Re: C# binary issue

by Stifu :: Rate this Message:

Reply to Author | View in Thread

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.


 « Return to Thread: C# binary issue