Print Page | Close Window

Debug Assertion Failed!

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=17708
Printed Date: 20 December 2024 at 1:20pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Debug Assertion Failed!
Posted By: tomay3000
Subject: Debug Assertion Failed!
Date Posted: 20 December 2010 at 6:35pm
When I use MFC as Statically Linked Library, a Debug Assertion Failure message box containing the following code in my app::InitInstance appears:

generated debug assertion
if (!ProcessShellCommand(cmdInfo))
return FALSE;
-- File: docsingl.cpp
Line: 215


However when using MFC as Shared DLL, this error is not coming and I'll get my window.
I am confused to figure out why !?

I have traced out that my program is failing at the big line of the following code:

void CSingleDocTemplate::SetDefaultTitle(CDocument* pDocument)
{
    CString strDocName;
    if (!GetDocString(strDocName, CDocTemplate::docName) ||
        strDocName.IsEmpty())
    {
              // use generic 'untitled'
                VERIFY(strDocName.LoadString(AFX_IDS_UNTITLED));
    }
    pDocument->SetTitle(strDocName);
}


If I use the AFX_IDS_UNTITLED in the resource string table & everything goes fine.

I don't want to do this.
Even if you don't use it in the string table, it should have worked fine. because AFX_IDS_UNTITLED is defined in afxres.h & the resource file uses this header file.

Other projects that do not use AFX_IDS_UNTITLED in the string table resource are working fine.

So I opened the compiled EXE file with a Resource Editor, I searched for the missing string. I found that is was right there: "sans nom" in FRENCH cause I build my project with FRENCH AppWizard.

I recreated my project using the ENGLISH, DEUTCH, SPANISH & ITALIC AppWizard, & figured out that the problem has gone.

& I thought that the problem is due to my system: "Windows XP Pro SP3 FRENCH Edition",  so I reinstalled the system that time: "Windows XP Pro SP3 ENGLISH Edition", & figured out that all the problems has gone, & all the projects created using the ENGLISH, FRENCH, DEUTCH, SPANISH & ITALIC AppWizard are working perfectly.

The problem is that I don't want to install "Windows XP Pro SP3 ENGLISH Edition".

Any ideas? Help me Please Cry

-------------
Product: Codejock ToolkitPro MFC v16.2.0
Platform: Microsoft Windows 8 Pro (64-bit)

Language: Microsoft Visual C++ v6.0 (MFC)



Replies:
Posted By: Oleg
Date Posted: 21 December 2010 at 4:50am
Standard thing. If you compile statically you must add MFC/Toolkit resources to your resources

open res\[app].rc2 file and add line

#include "AFXRES.RC"


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: tomay3000
Date Posted: 26 December 2010 at 1:57pm
Originally posted by oleg oleg wrote:

Standard thing. If you compile statically you must add MFC/Toolkit resources to your resources

open res\[app].rc2 file and add line

#include "AFXRES.RC"


The "afxres.rc" file is already included. Thank you for your help, but I found the solution:

Debug Assertion Failed! - Solved

I did many tests to reach to this solution. So what did I do!?

I created a sample SDI application & named it as FR using the Xtreme ToolkitPro 2009 (13.4.2) AppWizard & I choosed the French (France) (APPWZFRA.DLL) to include French resources, & link the MFC statically. When the project is created, I built it to create the executable file.

In the project directory you should see the Debug or the Release folder, depending on your project configuration. Enter that folder, & now you should see an .res file. In my case it's FR.res.

I am using Restorator 2007 as my default Resource Editor. So I opened FR.res file using it, & I searched for the string "sans nom" which means "Untitled" in English. I found it in the English (United States) String resources as you see in the image below. But that string & all other French strings should be in the French (France) String resources!!! That’s strange!


Now open the .rc file from the main project directory with a text editor. In my case it's FR.rc. & scroll to the end of page, you should see this part of code:
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//

#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)
#ifdef _WIN32
LANGUAGE 12, 1
#pragma code_page(1252)
#endif //_WIN32
#include "res\\FR.rc2"  // non-Microsoft Visual C++ edited resources <------------------------------ This is our nightmare :(
#include "l.fra\\afxres.rc"      // Standard components
#include "l.fra\\afxprint.rc"  // printing/print preview resources
#endif

#endif    // not APSTUDIO_INVOKED


The line:
#include "res\\FR.rc2"  // non-Microsoft Visual C++ edited resources

Should be moved to the end as follows:
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//

#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)
#ifdef _WIN32
LANGUAGE 12, 1
#pragma code_page(1252)
#endif //_WIN32
#include "l.fra\\afxres.rc"      // Standard components
#include "l.fra\\afxprint.rc"  // printing/print preview resources
#include "res\\FR.rc2"  // non-Microsoft Visual C++ edited resources <------------------------------ No nightmares anymore ;)
#endif

#endif    // not APSTUDIO_INVOKED


This is because, if we open the file FR.rc2 from the res folder, we should see this code:
//
// FR.RC2 - resources Microsoft Visual C++ does not edit directly
//

#ifdef APSTUDIO_INVOKED
    #error this file is not editable by Microsoft Visual C++
#endif //APSTUDIO_INVOKED

#include <XTToolkitPro.rc> <------------------------------ Xtreme ToolkitPro 2009 (13.4.2) English (United States) resources are included first :(

/////////////////////////////////////////////////////////////////////////////
// Add manually edited resources here...

/////////////////////////////////////////////////////////////////////////////

& the rest of resources inclusion will be appended to the English (United States) resources.

Now save the edited FR.rc file & rebuild your project. Then, open again FR.res file with an Resource Editor. Search for the string "sans nom". Now it should be in the French (France) String resources as shown in the image below.


That's all. & I hope that you have understood, sorry for my bad English ;)



-------------
Product: Codejock ToolkitPro MFC v16.2.0
Platform: Microsoft Windows 8 Pro (64-bit)

Language: Microsoft Visual C++ v6.0 (MFC)



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net