未处理的“System.NullReferenceException”类型的异常出现在 Stranded.exe 中,急

问题描述

出现了错误:未处理的“System.NullReferenceException”类型的异常出现在Stranded.exe中。其他信息:未将对象引用设置到对象的实例。为什么?高手们说说。这是有关一个directx的一个例子。提示出错的地方在:m_device->SetProperty(DIPROP_RANGE,&range.diph);/////////CGameController::CGameController(LPDIRECTINPUT8input,HWNDhwnd){//Savecopies.gThis=this;m_hwnd=hwnd;m_inputSystem=input;//Initializethegamecontroller.DIPROPRANGErange;DIDEVCAPScaps;m_inputSystem->EnumDevices(DI8DEVCLASS_GAMECTRL,(LPDIENUMDEVICESCALLBACK)gJSEnumDeviceCallBack,NULL,DIEDFL_ATTACHEDONLY);if(m_device){range.diph.dwSize=sizeof(DIPROPRANGE);range.diph.dwHeaderSize=sizeof(DIPROPHEADER);range.diph.dwHow=DIPH_BYOFFSET;range.lMin=-1000;range.lMax=1000;range.diph.dwObj=DIJOFS_X;m_device->SetProperty(DIPROP_RANGE,&range.diph);/////////出错的这个range.diph.dwObj=DIJOFS_Y;m_device->SetProperty(DIPROP_RANGE,&range.diph);if(SUCCEEDED(m_device->GetCapabilities(&caps)))m_numButtons=caps.dwButtons;elsem_numButtons=4;}}

解决方案

解决方案二:
debug一下,看看m_device是不是nullptr
解决方案三:
引用1楼hdt的回复:

debug一下,看看m_device是不是nullptr

编译的时候没有错误,运行的时候不正常。m_device应该不为空,因为前面有个判断:if(m_device),如果为空后面的应该执行不到吧
解决方案四:
听说是PC上没有游戏手柄时就会出现该异常(本人没有游戏手柄无法验证),但是我将输入引擎中游戏手柄相关的代码注释掉之后,该游戏是可以运行的
解决方案五:
if(m_device)//这里不为0就可以通过,
解决方案六:
在托管c++里面m_device有可能是nullptr我还没试过if(nullptr)是什么结果
解决方案七:
http://user.qzone.qq.com/397613266/blog/1326359474自己解决了

时间: 2024-09-18 16:16:13

未处理的“System.NullReferenceException”类型的异常出现在 Stranded.exe 中,急的相关文章

未处理的“System.NullReferenceException”类型的异常出现在 system.data.dll 中。

问题描述 usingSystem;usingSystem.Drawing;usingSystem.Collections;usingSystem.ComponentModel;usingSystem.Windows.Forms;usingSystem.Data;usingSystem.Data.SqlClient;namespacec2pmag{///<summary>///usermag的摘要说明.///</summary>publicclassusermag:System.Wi

未处理的“System.InvalidOperationException”类型的异常出现在system.web.services.dll中。其他信息: 客户端发现响应内容类型为“text/

问题描述 "C:WINDOWSMicrosoft.NETFrameworkv1.1.4322TemporaryASP.NETFileshuike.webservice205d4ef74c400ce7"下没有webservice编译生成后的dll文件,生成后应该有这样后缀名的文件.cs.cmdline.dll.err.out.pdb六个文件,但是现在我的电脑里打死不生成.dll的那个文件,程序运行不起来.请帮我看下下面的报错信息,到底是何问题啊?我今天要交任务的,谁知不能运行起来,我快气

请高手帮忙:未处理的“System.InvalidOperationException”类型的异常出现在 system.data.dll 中。其他信息: OleDbCommand 是当前正忙的 Open, Fetching。

问题描述 我的具体代码是:PublicClassForm1InheritsSystem.Windows.Forms.FormDimdatardAsSystem.Data.OleDb.OleDbDataReaderPrivateSubForm1_Load(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesMyBase.LoadOleDbCon.ConnectionString="provider=sqloledb;"Ol

未处理的“System.StackOverflowException”类型的异常出现在 System.Windows.Forms.dll 中。

问题描述 在程序中为DataGridView设置DataSource后出现如题目错误注释后不会有错我是在窗体的Load事件方法中设置的只是一个新窗体的实例化,怎么会有死循环呢?求教高手! 解决方案 解决方案二:代码不贴谁能知道啊?解决方案三:要是本窗体的话用this.就可以了!

System.NullReferenceException”类型的未经处理的异常出现在 WindowsFormsApplication2.exe 中。

问题描述 usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Data.SqlClient;usingSystem.Configuration;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;namespaceWindowsFormsApp

net 4.0-“System.NullReferenceException”类型的异常在 ls1.dll

问题描述 "System.NullReferenceException"类型的异常在 ls1.dll UserModel usermodel = new UserModel(); if ( Request["xingming"].Trim() != "输入姓名") { usermodel.name = Request["xingming"].Trim(); } if ( Request["shenfenzhen&qu

System.NullReferenceException”类型的未经处理的异常

问题描述 各位大神,在按钮中,为什么会报错.但是结果照样会写到txt中,而MessageBox.Show就显示不出来了,直接报错,求如何改进的办法.谢谢privatevoidbutton3_Click(objectsender,EventArgse){using(StreamWritersk=newStreamWriter(textBox4.Text+"Export_To_Text.txt",false,Encoding.GetEncoding("Unicode")

“System.InvalidOperationException”类型的异常在 EntityFramework.dll 中发生,但未在用户代码中进行处理

问题描述 "System.InvalidOperationException"类型的异常在EntityFramework.dll中发生,但未在用户代码中进行处理其他信息:无法确定类型"Dongxun.CMS.Data.Exam.TableModel.Constraint"的组合主键排序.请使用ColumnAttribute(请参阅http://go.microsoft.com/fwlink/?LinkId=386388)或HasKey(请参阅http://go.mi

求解“System.NotSupportedException”类型的异常!

问题描述 求解"System.NotSupportedException"类型的异常! ds无数据. 报错:ds.defaultViewManager.System.ComponentModel.IBindingList.IsSorted"引发了"System.NotSupportedException"类型的异常 解决方案 if ( ds == null ) throw new NotSupportedException(); } 增加这个判断看看 解决