Article ID: 150764 - Last Review: November 21, 2006 - Revision: 2.1 PRB: CString::LoadString Fails in Console ApplicationThis article was previously published under Q150764 On This PageSYMPTOMS
CString::LoadString() generates an MFC assert in debug mode console
applications or fails in release mode console applications.
CAUSE
CString::LoadString() relies on MFC global resource handles that are
initialized in AfxWinMain(), which is only called in MFC GUI-based
applications.
RESOLUTION
The resource string is loaded using the Win32 API ::LoadString() function.
This method does not require any extra MFC initialization. Example #1 below uses this method. It is possible to initialize the MFC global resource handles by calling the undocumented AfxWinInit() function. In this case, it is advisable to declare an instance of a CWinApp class. Example #2 below demonstrates this method. Sample Code - Example #1Sample Code - Example #2STATUS
This behavior is by design.
APPLIES TO
| Article Translations
|

Back to the top
