views:

33

answers:

1

Still getting used to this MFC lark and I've hit a brick wall on this particular problem. I'm updating some legacy code to use some of the more refined controls available in the MFC Feature Pack.

Following the examples given online for updating an old MFC app, changing the base application class to CWinAppEx works fine, but when I change CFrameWnd to CFrameWndEx, I get a Debug Assert Failed error message that comes from somewhere in mfc90d.dll!AFXGetRegPath. Ignoring this message leads to a slew of 0xC0000005: Access violation errors.

I'd be grateful for any suggestions on how to go about fixing this.

Cheers.

A: 

The source code for the MFC framework is included as part of Visual Studio, so it should be installed on your computer. In general, when the framework triggers a debug assertion you should drop into the debugger and this will help you determine the exact cause of the problem.

Looking at the source code, I can see that the AFXGetRegPath function contains a few assertions:

ENSURE(lpszPostFix != NULL);
ASSERT_VALID(pApp);
ENSURE(AfxGetApp()->m_pszRegistryKey != NULL);
ENSURE(AfxGetApp()->m_pszProfileName != NULL);

If I had to guess I'd say that it's the m_pszRegistryKey check that's failing, probably because you don't call SetRegistryKey in your app class's InitInstance function.

I hope this helps!

ChrisN
Your spider sense is finely tuned - that was exactly the problem, after setting the registry key it works. Still not sure why it only became an issue after changing CFrameWnd to CFrameWndEx, but I'm quite happy not to have to dig for the reason. Thanks a lot!
Monobounce