PRB: Assertion Failed: WINAPP.CPP, APPCORE.CPP, or WINMAIN.CPP

Last reviewed: July 31, 1997
Article ID: Q85496
7.00 | 1.00 1.50 | 1.00 2.00 2.10 4.00
MS-DOS | WINDOWS   | WINDOWS NT
kbprg kbfasttip kbprb

The information in this article applies to:

   The Microsoft Foundation Classes (MFC), included with:
    - Microsoft C/C++ compiler for MS-DOS, version 7.0
    - Microsoft Visual C++ for Windows, versions 1.0 and 1.5
    - Microsoft Visual C++, 32-bit Edition, versions 1.0, 2.0, 2.1, and
      4.0

SYMPTOMS

Running a Microsoft Foundation Classes (MFC) application developed with Microsoft C/C++ version 7.0 or Visual C++ for Windows may cause one of the following error messages to be displayed:

   Assertion failed - <unknown application>:File winapp.cpp, Line 258

   -or-

   Assertion failed - <unknown application>:File appcore.cpp, Line 602

Running a MFC application developed with Visual C++, 32-bit Edition, version 1.0 may cause the following error message to be displayed:

   Assertion failed - <unknown application>:File appcore.cpp, Line 559

Running a MFC application developed with Visual C++, 32-bit Edition, version 2.x, may cause the following error message to be displayed:

   Assertion failed - <unknown application>:File winmain.cpp, Line 40

Running a MFC application developed with Visual C++, 32-bit Edition, version 4.0, may cause the following error message to be displayed:

   Debug Assertion Failed!

   Program: <program_name>
   File: winmain.cpp
   Line: 34

NOTE: In Visual C++, 32-bit Edition, versions 2.0 and above, the assertion will be followed by an Application Error.

CAUSE

The assertion that fails is the check to see whether an application object exists. Without the application object, the program cannot run.

RESOLUTION

Define an object of a class derived from the CWinApp class.

MORE INFORMATION

An example of this error may be seen by commenting out the file scoped statement of any MFC application that defines the CWinApp-derived object. This statement will look similar to the following:

   CMyWinApp  MyWinApp;

where CMyWinApp is defined as follows:

   class CMyWinApp : public CWinApp
   {
      //...
   };

For an example MFC application, see the HELLOAPP sample program included with any of the Microsoft products listed above.

Chapter 3 of the "Microsoft C Class Libraries User's Guide," provided with Microsoft C/C++ version 7.0, and chapter 1 of the "Programming with MFC: Overview," included in the Visual C++ Books Online, contain additional information on CWinApp and on the fundamentals of using the Microsoft Foundation Classes to build an application for Windows.


Additional reference words: 7.00 1.00 1.50 2.00 2.10 2.50 3.00 4.00
KBCategory: kbprg kbfasttip kbprb
KBSubcategory: MfcMisc
Keywords : MfcMisc kbfasttip kbprb kbprg
Technology : kbMfc
Version : 7.00 | 1.00 1.50 | 1.00 2.00 2
Platform : MS-DOS NT WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 31, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.