473,792 Members | 2,796 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 12632
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
17626
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
3368
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
2069
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
4534
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
9422
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
1937
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
3809
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
1868
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)
0
9670
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10430
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10211
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10000
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
9033
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
7538
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
6776
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
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4111
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

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.