473,804 Members | 2,931 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Assertion in CWinApp::CWinAp p - AfxGetThread() == NULL

I have created an MFC project that links MFC MFC as shared dll and uses
/MD[d] . This MFC application loads another dll B via Loadlibrary that
has /MD[d] too and also links MFC as shared dll. Dll B again loads dll C
that also uses MFC as a shared DLL dll and also has /MD[d].

Also the MFC app statically links to a .lib that has MFC linked as
shared dll and has /MD[d]

Now for some odd reason when the constructor of my MFC app is called
(CMyMFCApp:CMyM FCApp) I get an assertion in CWinApp::CWinAp p in this
line: ASSERT(AfxGetTh read() == NULL); (appcore.cpp).

Any Idea what I possibly might be doing wrong.
Dec 7 '05 #1
3 12633
bonk wrote:
I have created an MFC project that links MFC MFC as shared dll and uses
/MD[d] . This MFC application loads another dll B via Loadlibrary that
has /MD[d] too and also links MFC as shared dll. Dll B again loads dll C
that also uses MFC as a shared DLL dll and also has /MD[d].

Also the MFC app statically links to a .lib that has MFC linked as
shared dll and has /MD[d]

Now for some odd reason when the constructor of my MFC app is called
(CMyMFCApp:CMyM FCApp) I get an assertion in CWinApp::CWinAp p in this
line: ASSERT(AfxGetTh read() == NULL); (appcore.cpp).

Any Idea what I possibly might be doing wrong.


A guess: You might be assuming in other constructors that the CMyMFCApp
object has already been constructed. The order of construction of
static objects is indeterminate, so you can't do much inside such
constructors.

--
Scott McPhillips [VC++ MVP]

Dec 7 '05 #2
Scott McPhillips [MVP] schrieb:
bonk wrote:
I have created an MFC project that links MFC MFC as shared dll and
uses /MD[d] . This MFC application loads another dll B via Loadlibrary
that has /MD[d] too and also links MFC as shared dll. Dll B again
loads dll C that also uses MFC as a shared DLL dll and also has /MD[d].

Also the MFC app statically links to a .lib that has MFC linked as
shared dll and has /MD[d]

Now for some odd reason when the constructor of my MFC app is called
(CMyMFCApp:CMyM FCApp) I get an assertion in CWinApp::CWinAp p in this
line: ASSERT(AfxGetTh read() == NULL); (appcore.cpp).

Any Idea what I possibly might be doing wrong.

A guess: You might be assuming in other constructors that the CMyMFCApp
object has already been constructed. The order of construction of
static objects is indeterminate, so you can't do much inside such
constructors.

I have found out that the Ctor of a CWinApp is called 2 times anly the
3rd time I get this assertion. Only the second time AfxGetThread()
return NOT NULL and therfore I get the assertion the 2nd time. The first
time th CTor is called it comes from a dll. the snd time that ctor is
called it comes from the exe.
Dec 7 '05 #3
On Wed, 07 Dec 2005 17:11:26 +0100, bonk <sc************ ******@gmx.de>
wrote:
I have found out that the Ctor of a CWinApp is called 2 times anly the
3rd time I get this assertion. Only the second time AfxGetThread()
return NOT NULL and therfore I get the assertion the 2nd time. The first
time th CTor is called it comes from a dll. the snd time that ctor is
called it comes from the exe.


Sounds like you have two or more CWinApp objects, and they're using the
same AfxGetThread data. I suppose this could happen if your libraries are
linking to different versions of MFC, including mixing of debug and release
versions. You might use Dependency Walker (depends.exe) to determine the
DLLs you link to implicitly, or the Sysinternals Process Explorer to
determine the DLLs you're using at runtime.

--
Doug Harrison
Visual C++ MVP
Dec 7 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
17630
by: Arti Potnis | last post by:
Hi, I have an application with a function "myfunction" that opens a file and writes to it using fprintf. This application runs on a unix (sun solaris 5.8) system. I connect to this application from a VB GUi on a windows 2000 system. The GUI invokes "myfunction". I get the following error:-
0
3369
by: bagnjm | last post by:
Hi, I have a huge VC6 MFC project that was converted to Visual Studio 2005 beta2. After the conversion, the application crashes because AfxGetThread() returns NULL and thus fail on pThread->InitInstance() inside AfxWinMain(). I have a CWinApp derived class (e.g. CBaseWinApp) exported from a DLL. This derived class is inherited inside the main app (e.g. CDerivedWinApp : public CBaseApp) and serves as the global app.
5
5306
by: Dan Trowbridge | last post by:
Hi All, I'm in the middle of porting code to VS.NET from VS6.0. My code compiles fine under DEBUG mode but under RELEASE mode I get a compile-time error: C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\afxwin2.inl(1034) : error C2039: 'Enable3dControls' : is not a member of 'CWinApp' C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\afxwin.h(4289) : see declaration of 'CWinApp'
0
2070
by: Milind Phadnis | last post by:
Hi, I have an application which was developed with Visual C++ 6.0 and MFC. In the application, the CWinApp::WinHelp method was overridden to support context sensitive help (F1 help). The application was recently upgraded to Visual Studio .Net 2003. The help links no longer work. The WinHelp method in my derived application class no longer gets called, when the user presses F1 in the application as before. The application instead looks...
17
4539
by: Mark A | last post by:
DB2 8.2 for Linux, FP 10 (also performs the same on DB2 8.2 for Windoes, FP 11). Using the SAMPLE database, tables EMP and EMLOYEE. In the followng stored procedure, 2 NULL columns (COMM) are selected into 2 different SP variables and compared for equal. They are both NULL, but do not compare as equal. When the Not NULL columns (SALARY) are compared, they do compare as equal.
4
9425
by: Mullai | last post by:
Hi , My program gives an error message like this Debug Assertion Failed! program:................ File: wincore.cpp Line: 958 Please can anyone help me out in this issue. I have to solve this bug immediately in my project.
1
1939
by: RiaanDP | last post by:
Hi, I'm currently working on integrating our company's management system into .NET. The system was originally created in Visual C++ 6.0, but new requirements point to that we may need to make use of .NET Web Services. I've already succeeded in getting all our system code to compile into a new C++ web service. The problem is that I need to "start" a the system from within the Web Service (I'm currently implementing this code in the...
15
3811
by: jacob navia | last post by:
Problem You want to ensure that a pointer argument to a function is non-null. Solution int fn(double data); This means that the array (that is passed as a pointer)
0
1869
by: =?Utf-8?B?REx1ZWNr?= | last post by:
I am getting a debug assertion error that reads: Debug Assertion Failed! program E:\program files\internet explorer\iexplore,exe File: dbgheap.c Line: 1252 Expression: _CrtIsValidHeapPointer(pUserData)
1
10315
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10075
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9140
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7615
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5519
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4295
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.