我有一个项目,直到最近才在Visual Studio 6.0中进行了编译,没有任何问题.我将此项目移到了Visual Studio2008. 在调试和发布模式下都可以正确编译. 它打开一个MS Access数据库文件并访问一个表. 它在发布模式下工作正常,但是当我尝试在调试模式下运行项目时,它将引发异常.在访问表后发生异常,我尝试移至下一条记录. 我已经复制了一些表明可能存在问题的输出. 感谢您的帮助.
I have a project that until recently was compiled in Visual Studio 6.0 with no problems. I moved this project to Visual Studio 2008. It compiles without error in both debug and release mode. It opens up a MS Access database file and accesses a table. It works fine in Release Mode, but when I attempt to run the project in Debug mode it throws an exception. The exception occurs after the table is accessed and I attempt to move to the next record. I have copied some of the output that indicates a possible problem. Thanks for your help.
'Proj.exe': Loaded 'C:\WINDOWS\system32\odbcint.dll', Binary was not built with debug information. Warning: ODBC Success With Info, Driver's SQLSetConnectAttr failed State:IM006,Native : 0,Origin:[Microsoft][ODBC Driver Manager] DBMS: ACCESS Version: 04.00.0000 ODBC Driver Manager Version: 03.52.0000 Warning: ODBC Success With Info, String data, right truncated State:01004,Native:5,Origin:[Microsoft][ODBC Microsoft Access Driver] 'Proj.exe': Loaded 'C:\WINDOWS\system32\expsrv.dll', Cannot find or open a required DBG file. Warning: Setting forwardOnly recordset readOnly.推荐答案
可能有不同的原因.顺便说一句,您提供的是输出,而不是异常.请提供完整的异常转储,并在发生异常时显示类似的代码.为什么要强迫我们进行猜测? 无论如何,都有典型的常见问题导致这种情况.可能最常见的是由于对文件路径的错误假设而导致无法在其中一种配置中找到某些文件.顺便说一句,即使在Release配置中,也可以使用Debugger.差异很可能不是由于在调试器下运行,而是由于项目配置不同而导致的,这是不一样的.在带有发布配置的调试器下运行;您可能会看到是否仍然找不到该文件. 在运行时,您永远不应假定任何特定的工作目录.工作目录取决于Configuration,但实际上它是由用户在启动应用程序时定义的.绝对不要使用绝对路径,也不要因为环境变量而假定该路径是可见的.这意味着您需要在运行时计算数据文件的路径.此路径可以是相对于您的可执行模块的路径(但通常仅是在不可变数据的情况下)或特定目录之一,例如所有用户"应用程序数据等. 进一步了解问题需要更多的异常信息.首先,代码行发生的地方.由于您的问题在Debugger中得到了体现,所以这并不难:您可以捕获异常,在捕获异常的地方放置一个断点,并使用Visual Studio Debug->查找堆栈. Windows->调用堆栈.这足以在发生的代码中找到我们的代码,以便在CodeProject问题中进行报告. 以编程方式转储它比较困难.我尚未在C ++中完成此操作(在.NET中是标准API的一部分),但Google搜索显示一个简单的C ++函数调用堆栈跟踪实用程序 [ ^ ], stackoverflow/questions/3355683/c-stack-trace -from-unhandled-exception [ ^ ], stackoverflow/questions/1796225 /get-stack-trace-from-uncaught-exception [ ^ ].
该消息表明调试器无法找到dbg文件,仅是信息,而不是错误.您的程序应在有或没有它的情况下运行. 以及警告:将forwardSet记录集设置为readOnly."只是警告,您在使用forwardOnly时应在选项中设置readOnly标志,而您的记录集类会为您做到这一点. 好吧,这使我们完全没有错误信息. 我建议您追溯到您可以控制的代码的最后一点,并开始检查您所做的所有系统调用的参数值. The message saying the debugger cannot find a dbg file, is just information, not an error. Your program should run with or without it. And "Warning: Setting forwardOnly recordset readOnly." is just a warning saying you should have set the readOnly flag in the options when using forwardOnly, and that your record set class does it for you. Well, that leaves us with no error information at all. I suggest you trace back to the last point in the code you have control, and start checking parameter values to all system calls you make.
我知道我没有太大帮助,但是我正在尝试.该应用程序已经运行了两年,没有任何问题.现在,它已在Visual Studio 2008中运行,无法在调试模式下使用.释放模式很好.这是炸毁的地方.在返回语句之后.返回AfxCallWndProc(pWnd,hWnd,nMsg,wParam,lParam); 前三个参数具有地址,而wParam和lParam没有.当我尝试移至下一条记录时,发生错误.希望能有所帮助. I know I''m not helping much but I''m trying. This application has been working for two years without a problem. Now that it is in Visual Studio 2008 it doesn''t work in Debug mode. Release mode is fine. Here is where it blows up. After the return statement. return AfxCallWndProc(pWnd, hWnd, nMsg, wParam, lParam); The first 3 parameters have addresses while wParam and lParam do not. The error occurs when I attempt to move to the next record. Hope that helps. AfxWndProc(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam) { // special message which identifies the window as using AfxWndProc if (nMsg == WM_QUERYAFXWNDPROC) return 1; // all other messages route through message map CWnd* pWnd = CWnd::FromHandlePermanent(hWnd); ASSERT(pWnd != NULL); ASSERT pWnd==NULL || pWnd->m_hWnd == hWnd); if (pWnd == NULL || pWnd->m_hWnd != hWnd) return ::DefWindowProc(hWnd, nMsg, wParam, lParam); return AfxCallWndProc(pWnd, hWnd, nMsg, wParam, lParam); }
更多推荐
项目仅在调试模式下引发异常
发布评论