0

我正在使用 Visual Studio 2010 来试验 MFC。

我按照向导创建了一个模板 MFC 项目。我选择了一个基于对话框的应用程序,并取消选中其他选项,如 ActiveX 控件。

没有进行任何代码更改后,我按 F5,应用程序运行。

然后,使用表单设计器,我将一个富编辑控件从工具箱拖到应用程序上。我再次按 F5,应用程序编译但立即以错误代码 0 退出。

为什么会发生这种情况?我究竟做错了什么?

这是包含 RichEdit 时的输出:

'odpmfc2.exe': Loaded 'C:\Visual Studio 2010\Projects\odpmfc2\Debug\odpmfc2.exe', Symbols loaded.
'odpmfc2.exe': Loaded 'C:\Windows\System32\ntdll.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\kernel32.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\KernelBase.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\mfc100ud.dll', Symbols loaded.
'odpmfc2.exe': Loaded 'C:\Windows\System32\msvcr100d.dll', Symbols loaded.
'odpmfc2.exe': Loaded 'C:\Windows\System32\user32.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\gdi32.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\lpk.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\usp10.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\msvcrt.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\shlwapi.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.7600.16385_none_ebf82fc36c758ad5\comctl32.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\advapi32.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\sechost.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\rpcrt4.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\msimg32.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\oleaut32.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\ole32.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\apphelp.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\AppPatch\AcLayers.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\sspicli.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\shell32.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\userenv.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\profapi.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\winspool.drv', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\mpr.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\imm32.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\msctf.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\uxtheme.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\dwmapi.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\mfc100enu.dll', Binary was not built with debug information.
The program '[7420] odpmfc2.exe: Native' has exited with code 0 (0x0).

发生所有这些加载错误有点可疑。但是,如果出现问题,为什么它会以错误代码 0 退出?

这是成功运行的输出。加载失败仍然发生:

'odpmfc2.exe': Loaded 'C:\Visual Studio 2010\Projects\odpmfc2\Debug\odpmfc2.exe', Symbols loaded.
'odpmfc2.exe': Loaded 'C:\Windows\System32\ntdll.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\kernel32.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\KernelBase.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\mfc100ud.dll', Symbols loaded.
'odpmfc2.exe': Loaded 'C:\Windows\System32\msvcr100d.dll', Symbols loaded.
'odpmfc2.exe': Loaded 'C:\Windows\System32\user32.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\gdi32.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\lpk.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\usp10.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\msvcrt.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\shlwapi.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.7600.16385_none_ebf82fc36c758ad5\comctl32.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\advapi32.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\sechost.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\rpcrt4.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\msimg32.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\oleaut32.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\ole32.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\apphelp.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\AppPatch\AcLayers.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\sspicli.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\shell32.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\userenv.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\profapi.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\winspool.drv', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\mpr.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\imm32.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\msctf.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\uxtheme.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\dwmapi.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\mfc100enu.dll', Binary was not built with debug information.
'odpmfc2.exe': Loaded 'C:\Windows\System32\cryptbase.dll', Cannot find or open the PDB file
'odpmfc2.exe': Loaded 'C:\Windows\System32\clbcatq.dll', Cannot find or open the PDB file
The program '[7956] odpmfc2.exe: Native' has exited with code 0 (0x0).

更新我删除了 RichEdit,并添加了这些其他控件,它工作正常:

  • MFC VSListBox 控件
  • 列表控件
  • MFC 链接控制
  • 网络地址控制

Tangent : 为什么 RichEdit2 是表单生成器中唯一可用的 RichEdit?(我在 Windows 7 上使用 VS 2010)

4

1 回答 1

1

解决方案:我需要添加这个调用:

LoadLibrary(TEXT("riched20.dll"));

MSDN所述:

在 Microsoft Visual Studio 2005 及更高版本中,可以通过从工具箱中拖动控件来将富编辑控件添加到对话框模板中。但是,在对话框编辑器中执行此操作并不能确保在创建控件之前加载所需的库。在创建对话框之前,需要调用 LoadLibrary 函数来加载 Riched32.dll、Riched20.dll 或 Msftedit.dll。

于 2010-07-12T23:17:49.707 回答