Click here to Skip to main content
15,746,652 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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 bolded line of the following code:

void CSingleDocTemplate::SetDefaultTitle(CDocument* pDocument)
    CString strDocName;
    if (!GetDocString(strDocName, CDocTemplate::docName) ||
              // use generic 'untitled'

If I use the AFX_IDS_UNTITLED in the resource string table & everything went 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 :((

1 solution

It seems to me, that during creating your project you used check box "Use dymanic link to MFC". When using static link to MFC application should call static MFC initialization function.

#ifdef _AFXDLL
    Enable3dControls();         // Call this when using MFC in a shared DLL
    Enable3dControlsStatic();   // Call this when linking to MFC statically

This is for VC 6.0.
Also you may need to remove defininition _AFXDLL from project settings.
Share this answer
Mr. Tomay 21-Dec-10 19:05pm    
I checked that my project settings has no _AFXDLL definition :(

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900