The information in this article applies to:
SYMPTOMSA Windows-based application using the DLL version of the CRT (C run-time) causes a run-time error and exits without displaying any error message or notification. CAUSEThere are two ways to notify a user of a run-time error -- one for Windows- based applications and one for console-based applications. A Windows-based application linked with the static CRT pops up a dialog box with the run-time error number. A console-based application outputs the error message to stderr. However a Windows-based application using the CRT DLL calls the console version, which outputs to stderr. Because stderr does nothing in a Windows-based application, the application terminates without giving a warning or notification. RESOLUTION
Here are two workarounds for a Windows-based application using the CRT DLL:
The initialization part of the sample code should execute before any other global data initialization. Within a source file, the order of execution will be in the order the initializations appear in the file. In order to ensure that the initialization code is executed first, place the code within that compilation unit at the top of the file, after include files. The order of initialization of data in different compilation units cannot be guaranteed. If your application is still exiting without a message you can use the first workaround, or you can place all your global data in the same compilation unit, with the sample initialization code at the top of the file. The termination section of the sample code is used for the normal termination of the application. It ensures that the console window is destroyed when the application terminates. For MFC applications, place the termination code in the application object's ExitInstance() member function. In a non-MFC Windows-based application, place this code in the WM_DESTROY message hanlder. STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This problem was corrected in Visual C++ 4.0 REFERENCESSample Code - Initialization Section
Sample Code - Termination Section
Additional query words: 2.00 2.10 2.20 3.00 3.50 3.51 4.00
Keywords : kbcode kbnokeyword kbMFC kbVC LibIss |
Last Reviewed: August 3, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |