MFC can't load error string resources in dbcor

2019-09-13 17:59发布

问题:

I have an old MFC application I've recently updated to include code that uses CDatabase to access an old MDB.

This works, but when an internal error occurs, I get an assertion in dbcore.cpp that it could not load the error string resource.

After some research, I added the following line to my application's RC file.

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#ifndef APSTUDIO_INVOKED
#include "targetver.h"
#endif
#include "afxres.h"
#include "afxdb.rc"  // <<======= I ADDED THIS LINE HERE!!!

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

This solved the problem. I now got a meaningful message for internal errors. However, now if I try to save my resource file using the resource editor, I get an error.

How can I get meaningful internal database messages and still be able to save changes to my resource file?

回答1:

Per Joe Willcoxson's comment, moving the added line to my RC2 file solved the issue. I now have the necessary database resources, and I'm still able to edit and save resources in the resource editor.