在VS2010中使用MFC模板项目很困难

时间:2010-07-12 22:59:04

标签: c++ visual-studio-2010 mfc richedit

我正在使用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)

1 个答案:

答案 0 :(得分:1)

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

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

正如MSDN所述:

  

在Microsoft Visual Studio 2005和   之后,可以添加一个丰富的   通过控件将控件编辑为对话框模板   从工具箱中拖动控件。   但是,在对话框中执行此操作   编辑不保证   之前将加载所需的库   控件已创建。它是   调用LoadLibrary所必需的   函数加载Riched32.dll,   Riched20.dll或之前的Msftedit.dll   对话框已创建。