救急啊,创建了个MFC项目出现不明BUG

C++语言 码拜 9年前 (2015-05-11) 1520次浏览 0个评论
 

用vs2010的MFC向导创建了个对话框项目,就加了个Button和RichEdit,然后用向导创建不了Button的单击事件就自己手动加了个,然后运行程序,程序跑了下就自动退出了。
输出窗口有如下提示,怎么解决呢

“ACSProject.exe”: 已加载“C:\Documents and Settings\tianxinwei\桌面\ACSProject\Debug\ACSProject.exe”,已加载符号。
“ACSProject.exe”: 已加载“C:\WINDOWS\system32\ntdll.dll”,Cannot find or open the PDB file
“ACSProject.exe”: 已加载“C:\WINDOWS\system32\kernel32.dll”,Cannot find or open the PDB file
“ACSProject.exe”: 已加载“C:\WINDOWS\system32\mfc100ud.dll”,已加载符号。
“ACSProject.exe”: 已加载“C:\WINDOWS\system32\msvcr100d.dll”,已加载符号。
“ACSProject.exe”: 已加载“C:\WINDOWS\system32\user32.dll”,Cannot find or open the PDB file
“ACSProject.exe”: 已加载“C:\WINDOWS\system32\gdi32.dll”,Cannot find or open the PDB file
“ACSProject.exe”: 已加载“C:\WINDOWS\system32\shlwapi.dll”,Cannot find or open the PDB file
“ACSProject.exe”: 已加载“C:\WINDOWS\system32\advapi32.dll”,Cannot find or open the PDB file
“ACSProject.exe”: 已加载“C:\WINDOWS\system32\rpcrt4.dll”,Cannot find or open the PDB file
“ACSProject.exe”: 已加载“C:\WINDOWS\system32\secur32.dll”,Cannot find or open the PDB file
“ACSProject.exe”: 已加载“C:\WINDOWS\system32\msvcrt.dll”,Cannot find or open the PDB file
“ACSProject.exe”: 已加载“C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.6028_x-ww_61e65202\comctl32.dll”,Cannot find or open the PDB file
“ACSProject.exe”: 已加载“C:\WINDOWS\system32\msimg32.dll”,Cannot find or open the PDB file
“ACSProject.exe”: 已加载“C:\WINDOWS\system32\oleaut32.dll”,Cannot find or open the PDB file
“ACSProject.exe”: 已加载“C:\WINDOWS\system32\ole32.dll”,Cannot find or open the PDB file
“ACSProject.exe”: 已加载“C:\WINDOWS\system32\imm32.dll”,Cannot find or open the PDB file
“ACSProject.exe”: 已加载“C:\WINDOWS\system32\lpk.dll”,Cannot find or open the PDB file
“ACSProject.exe”: 已加载“C:\WINDOWS\system32\usp10.dll”,Cannot find or open the PDB file
“ACSProject.exe”: 已加载“C:\WINDOWS\system32\uxtheme.dll”,Cannot find or open the PDB file
“ACSProject.exe”: 已加载“C:\WINDOWS\system32\mfc100chs.dll”,未使用调试信息生成二进制文件。
“ACSProject.exe”: 已加载“C:\WINDOWS\system32\shell32.dll”,Cannot find or open the PDB file
“ACSProject.exe”: 已加载“C:\Program Files\360\360Safe\safemon\safemon.dll”,Cannot find or open the PDB file
“ACSProject.exe”: 已加载“C:\WINDOWS\system32\psapi.dll”,Cannot find or open the PDB file
“ACSProject.exe”: 已加载“C:\WINDOWS\system32\wininet.dll”,Cannot find or open the PDB file
“ACSProject.exe”: 已加载“C:\WINDOWS\system32\crypt32.dll”,Cannot find or open the PDB file
“ACSProject.exe”: 已加载“C:\WINDOWS\system32\msasn1.dll”,Cannot find or open the PDB file
“ACSProject.exe”: 已加载“C:\WINDOWS\system32\version.dll”,Cannot find or open the PDB file
“ACSProject.exe”: 已加载“C:\WINDOWS\system32\ws2_32.dll”,Cannot find or open the PDB file
“ACSProject.exe”: 已加载“C:\WINDOWS\system32\ws2help.dll”,Cannot find or open the PDB file
“ACSProject.exe”: 已加载“C:\WINDOWS\system32\netapi32.dll”,Cannot find or open the PDB file
“ACSProject.exe”: 已加载“C:\WINDOWS\system32\MSCTF.dll”,Cannot find or open the PDB file
“ACSProject.exe”: 已加载“C:\WINDOWS\system32\MSCTFIME.IME”,Cannot find or open the PDB file
Detected memory leaks!
Dumping objects ->
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\occmgr.cpp(195) : {444} normal block at 0x0039D740, 32 bytes long.
 Data: <                > 01 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\occmgr.cpp(181) : {443} normal block at 0x0039D6F0, 20 bytes long.
 Data: <                > FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 
Object dump complete.
程序“[5492] ACSProject.exe: 本机”已退出,返回值为 0 (0x0)。

向导怎么创建不了单击响应? 在设计里按钮上双击即自动添加
引用 1 楼 focuslight 的回复:

向导怎么创建不了单击响应? 在设计里按钮上双击即自动添加

手动添加之前确实自动添加不了,双击按钮没反应,右键按钮选择类向导还是添加事件都没反应,在类属性事件栏找到ID点开之后选择BN_CLICKED也是添加不了,说是无效的值。最后在网上搜了下所那只能手动添加了,手动添加了之后我试了下现在可以自动添加了。

上面这个问题是怎么回事呢,大家给看看

引用 1 楼 focuslight 的回复:

向导怎么创建不了单击响应? 在设计里按钮上双击即自动添加

我加断点调试了下
在crtexe.c文件的__declspec(noinline) int __tmainCRTStartup( void )函数中
             /*
             * Note that if the exe is managed app, we don””t really need to
             * call exit or _c_exit. .cctor should be able to take care of
             * this.
             */
            if ( !managedapp )//这里managedapp为0,所以退出了
                exit(mainret);

            if (has_cctor == 0)
                _cexit();

会退出
而managedapp 是在managedapp = check_managed_app();这里被赋值
而/***
*check_managed_app() – Check for a managed executable
*
*Purpose:
*       Determine if the EXE the startup code is linked into is a managed app
*       by looking for the COM Runtime Descriptor in the Image Data Directory
*       of the PE or PE+ header.
*
*Entry:
*       None
*
*Exit:
*       1 if managed app, 0 if not.
*
*Exceptions:
*
*******************************************************************************/

static int __cdecl check_managed_app (
        void
        )
{
        PIMAGE_DOS_HEADER pDOSHeader;
        PIMAGE_NT_HEADERS pPEHeader;

        pDOSHeader = &__ImageBase;

        if (pDOSHeader->e_magic != IMAGE_DOS_SIGNATURE)
        {
            return 0;
        }

        pPEHeader = (PIMAGE_NT_HEADERS) ((BYTE *) pDOSHeader + pDOSHeader->e_lfanew);

        if (pPEHeader->Signature != IMAGE_NT_SIGNATURE)
        {
            return 0;
        }

        if (pPEHeader->OptionalHeader.Magic != IMAGE_NT_OPTIONAL_HDR_MAGIC)
        {
            return 0;
        }

        /* prefast assumes we are overflowing __ImageBase */
#pragma warning(push)
#pragma warning(disable:26000)
        if (pPEHeader->OptionalHeader.NumberOfRvaAndSizes <= IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR)
        {
            return 0;
        }
#pragma warning(pop)

        return pPEHeader->OptionalHeader.
             DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].VirtualAddress != 0;
}
前面都没return 0,而是在最后一句中DataDirectory数组中它的第IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR=14元素的VirtualAddress 为0,所以返回了0

15分
代码功能归根结底不是别人帮自己看或讲解或注释出来的;而是被自己静下心来花足够长的时间和精力亲自动手单步或设断点或对执行到某步获得的中间结果显示或写到日志文件中一步一步分析出来的。
提醒:再牛×的老师也无法代替学生自己领悟和上厕所!
单步调试和设断点调试是程序员必须掌握的技能之一。
Debug|DebugRunToCursor                |Ctrl+F10              |Runs the program to the line containing the cursor
Debug|DebugEnableBreakpoint           |Ctrl+F9               |Enables or disables a breakpoint
Debug|DebugRestart                    |Ctrl+Shift+F5         |Restarts the program
Debug|DebugRemoveAllBreakpoints       |Ctrl+Shift+F9         |Removes all breakpoints
Debug|DebugStepOver                   |F10                   |Steps over the next statement
Debug|DebugStepInto                   |F11                   |Steps into the next statement
Debug|DebugGo                         |F5                    |Starts or continues the program
Debug|DebugToggleBreakpoint           |F9                    |Inserts or removes a breakpoint
Debug|DebugStepOut                    |Shift+F11             |Steps out of the current function
Debug|DebugStopDebugging              |Shift+F5              |Stops debugging the program
Debug|DebugQuickWatch                 |Shift+F9              |Performs immediate evaluation of variables and expressions
25分
向导文件已损坏, 重建工程吧, 就两个控件
楼主怎么解决这个问题的,我也是这个问题,那个虚拟地址为空是怎么回事?
BOOL ***App::InitInstance()
{
AfxEnableControlContainer();
AfxInitRichEdit();//加上这行

———————————-应该是richEdit的问题


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明救急啊,创建了个MFC项目出现不明BUG
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!