简体   繁体   中英

How can i find what cause a null exception ? I mean what line or where in the code the exception throw?

I'm running my program and after some time it's working it's throwing this exception:

Directx例外

I'm using directx in my program and also direct3d in the top of the form i did:

using Microsoft.DirectX.Direct3D;
using Microsoft.DirectX;

And i'm using in my program with Direct3D.Sprite and Device and Texture PresentParameters and DisplayMode all connected to the DirectX.Direct3D

And in the exception message it's saying something about OnLostDevice() and others. But it dosen't give any specific line or where in the code the problem is.

Is there any way to find what cause the problem ?

System.NullReferenceException was unhandled
  HResult=-2147467261
  Message=Object reference not set to an instance of an object.
  Source=Microsoft.DirectX.Direct3DX
  StackTrace:
       at Microsoft.DirectX.Direct3D.Sprite.OnLostDevice()
       at Microsoft.DirectX.Direct3D.Sprite.OnParentLost(Object sender, EventArgs e)
       at System.EventHandler.Invoke(Object sender, EventArgs e)
       at Microsoft.DirectX.Direct3D.Device.raise_DeviceLost(Object i1, EventArgs i2)
       at Microsoft.DirectX.Direct3D.Device.Finalize()
  InnerException: 

For start put the Configuration of the project to Debug . At the moment you are in Release ! In your screenshot you can see it to the Continue button. After that you should Debug you project.

When you are in Debug, you can see the exact line which throw exception when you check the checkbox in Debug/Exceptions/Common Language Runtime Exceptions .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM