开发者

Difficulty with MFC template project in VS2010

I'm using Visual Studio 2010 to experiment with MFC.

I have created a template MFC project by following the wizard. I chose a dialog based app, and unchecked other options like ActiveX controls.

After making no code changes, I hit F5, and the app runs.

Then, using the form designer, I drag a rich edit control from the toolbox onto the app. I hit F5 again, and the app compiles but exits with error code 0 instantly.

Why could this be happening? What am I doing wrong?

This is the output when the RichEdit is included:

'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': L开发者_开发百科oaded '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).

It is a bit suspicious that all these load errors are occurring. But if something is going wrong, why is it exiting with error code 0?

Here is the output from a successful run. The load failures still occur:

'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).

UPDATE I removed the RichEdit, and added these other controls, and it works fine:

  • MFC VSListBox Control
  • List Control
  • MFC Link Control
  • Network Address Control

Tangent: Why is RichEdit2 the only RichEdit available in the form builder? (I'm using VS 2010 on Windows 7)


Solution: I needed to add this call:

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

As noted on MSDN:

In Microsoft Visual Studio 2005 and later, it is possible to add a rich edit control into a dialog template by dragging the control from the toolbox. However, doing this in the dialog editor does not ensure that the required library will be loaded before the control is created. It is necessary to call the LoadLibrary function to load Riched32.dll, Riched20.dll, or Msftedit.dll before the dialog is created.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜