0

After my game has been running for a certain amount of time, the same Warning shows up and my game breaks. I am not sure why this is and I cannot find a solution for it.

The message that keeps popping up is as follows:

Microsoft Visual Studio Express 2013 for Windows Desktop

An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in System.Drawing.dll

Additional information: The operation completed successfully

I have an Object class that deals with all of the Objects displayed on screen (position, collisions etc) and the warning seems to be coming from this class. When the warning is displayed, one line in-particular is highlighted every time, that is:

public Obj(Vector2 pos)
    {
        position = pos;
    }

Any help resolving my problem will be appreciated

Community
  • 1
  • 1
Kieren Wells
  • 65
  • 1
  • 6
  • 1
    You have an exception. Run your game in debug, and turn on First Chance Exceptions (Tools -> Exceptions -> CLR Exceptions) – Yuval Itzchakov Jun 22 '15 at 11:07
  • @Yuval Itzchakov this is not a CLR exception Prima facie, it needs to enable Win32 exceptions and need appropriate pdb files to look in the exact stack generated at runtime, using a tool like adplus – Mrinal Kamboj Jun 22 '15 at 11:12
  • @YuvalItzchakov I have looked in my Debug > Exceptions > CLR Exceptions and there is already a tick under User-Unhandled but not one under thrown – Kieren Wells Jun 22 '15 at 11:14
  • @MrinalKamboj thanks, what would I need to do in order to resolve my issue? – Kieren Wells Jun 22 '15 at 11:14

1 Answers1

0

You have an exception in an unmanaged component of your game. Go to Debug -> Exceptions and tick the "user-unhandled" box in the Win32 Exceptions row.

This way, your debugger will break whenever a Win32 exception is thrown, and if you have the required symbols loaded, you'll be able to debug the code as you normally would.

Furthermore, you can obtain the last Win32 error code using the Marshal.GetLastWin32Error method. Armed with that information, you should be able to figure out what your code is throwing on precisely, and how to resolve it.

aevitas
  • 3,753
  • 2
  • 28
  • 39
  • I have checked my Debug > Exception and Win32 User-unhandled was already ticked. The warning seems to be thrown on the line `public Obj(Vector2 pos) { position = pos; }` but I don't know why, I am pretty new to programming so I haven't a clue what to do – Kieren Wells Jun 22 '15 at 11:16
  • Do you happen to have "thrown" checked as well? Win32 and especially GDI (which is probably what you're using) is known to throw exceptions for pretty much everything. You shouldn't have "thrown" checked for that reason, only the unhandled ones should interest you. – aevitas Jun 22 '15 at 11:23
  • I do not have "thrown" checked, just user-unhandled – Kieren Wells Jun 22 '15 at 11:26