PRB: CWinApp-Based DLL Gets Assertion Failure on Win32s (119333)
The information in this article applies to:
- The Microsoft Foundation Classes (MFC)
This article was previously published under Q119333 SYMPTOMS
There is no problem starting a second instance of a Win32-based application
that uses a CWinApp-based DLL on Windows NT. However, under Win32s, the
same Win32-based application generates an assertion failure in the file
APPCORE.CPP, line 193.
CAUSE
The inability to run two applications that use the same CWinApp-based DLL
is because of differences in the way Windows NT and Win32s manage memory
and the fact that the C run-time initializes global data and objects
whenever a process loads a DLL.
Under Windows NT, each application gets its own copy of the DLL data,
including the C run-time and MFC data. Under Win32s, all applications that
use the DLL share the DLL data. When another process loads the DLL, the
global objects are reinitialized. The assertion is generated because
another copy of the CWinApp data already exists.
RESOLUTION
Replace the DLL entry point to work around the limitation. The sample code
to do this is shown in the "MORE INFORMATION" section. The new entry point
checks to see whether Win32s is loaded. If the application is running under
Win32s, the entry point makes sure that the C run-time entry point is
called only for the first process attach and the last process detach. This
problem has been fixed in Microsoft Visual C++ 32-bit edition, versions 2.0
and 2.1.
Modification Type: | Major | Last Reviewed: | 10/2/2003 |
---|
Keywords: | kbDLL kbprb KB119333 |
---|
|