调试断言失败! [英] Debug Assertion Failed!

查看:269
本文介绍了调试断言失败!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将 MFC 用作静态链接库时,在我的app::InitInstance中会出现一个包含以下代码的调试断言失败"消息框:

生成的调试断言
如果(!ProcessShellCommand(cmdInfo))
返回FALSE;
-文件:docsingl.cpp
线:215


但是,当使用 MFC 作为共享DLL 时,此错误不会出现,我将获得窗口.
我很想知道为什么!?

我已发现我的程序在以下代码的粗体行处失败:

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) ||
        strDocName.IsEmpty())
    {
              // use generic ''untitled''
                VERIFY(strDocName.LoadString(AFX_IDS_UNTITLED));
    }
    pDocument->SetTitle(strDocName);
}



如果我在资源字符串表&中使用 AFX_IDS_UNTITLED 一切都很好.

我不想这样做.
即使您不在字符串表中使用它,它也应该可以正常工作.因为 AFX_IDS_UNTITLED 是在 afxres.h &中定义的资源文件使用此头文件.

其他在字符串表资源中不使用 AFX_IDS_UNTITLED 的项目也可以正常工作.

因此,我用资源编辑器打开了已编译的 EXE 文件,我搜索了缺少的字符串.我发现那是正确的: FRENCH 中的"sans nom" 因为我用 FRENCH AppWizard 构建我的项目.

我使用 ENGLISH DEUTCH SPANISH &重新创建了我的项目. ITALIC AppWizard ,&发现问题已经解决了.

&我认为问题出在我的系统上:"Windows XP Pro SP3法语版" ,所以我当时重新安装了系统:"Windows XP Pro SP3英文版" ,&发现所有问题都消失了,使用 ENGLISH FRENCH DEUTCH SPANISH &创建的所有项目 ITALIC AppWizard 运行正常.

问题是我不想安装"Windows XP Pro SP3简体中文版" .

有任何想法吗?帮帮我:((<



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 :((

推荐答案

在我看来,在创建项目时,您使用了使用动态链接到MFC的复选框"使用静态链接到MFC应用程序时,应调用静态MFC初始化函数.

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
#else
    Enable3dControlsStatic();   // Call this when linking to MFC statically



这是用于VC 6.0的.
另外,您可能需要从项目设置中删除定义_AFXDLL.



This is for VC 6.0.
Also you may need to remove defininition _AFXDLL from project settings.


这篇关于调试断言失败!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆