Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

Visual Studio Crash in Add Class Wizard using CDHtmlDialog as the Base Class


Symptoms

When using the Add Class Wizard to wrap a Dialog resource with an MFC class that uses the CDHtmlDialog class as the base class, the Visual Studio IDE may crash.

↑ Back to the top


Cause

This is a bug in the Visual Studio Add Class Wizard scripting code.

↑ Back to the top


Resolution

Currently, there is no hotfix available for this bug. However, to work around you can modify the Add Wizard script code to fix the bug.

Open the default.js file c:\Program Files\Microsoft Visual Studio 9.0\VC\VCWizards\CodeWiz\MFC\Simple\scripts\1033\default.js  in a text editor.

At line 126, move the CloseResourceFile() function call to after the AddSymbol() call, i.e.

Change

    if (strBaseClass == "CDHtmlDialog")
    {
        RenderAddTemplate(wizard, "dhtmldlg.htm", strHTMLFile, selObj, false);
        oResHelper.OpenResourceFile(strProjectRC);
        var strSymbolValue = oResHelper.AddResource(strHTMLID, strProjectPath + strHTMLFile, "HTML");
        if (strSymbolValue == null) return;    
        oResHelper.CloseResourceFile();
        wizard.AddSymbol("HTML_ID", strSymbolValue.split("=").shift());
    }

To

    if (strBaseClass == "CDHtmlDialog")
    {
        RenderAddTemplate(wizard, "dhtmldlg.htm", strHTMLFile, selObj, false);
        oResHelper.OpenResourceFile(strProjectRC);
        var strSymbolValue = oResHelper.AddResource(strHTMLID, strProjectPath + strHTMLFile, "HTML");
        if (strSymbolValue == null) return;    
        //oResHelper.CloseResourceFile();
        wizard.AddSymbol("HTML_ID", strSymbolValue.split("=").shift());
        oResHelper.CloseResourceFile();
    }

Note that any hotfixes or service packs produced in the future that modify the default.js file may require you to redo these changes.

↑ Back to the top


More Information

You can reproduce the crash with the following steps.
  1. Create a new MFC Application project. Use all default settings
  2. In the new project, open the Resource view
  3. Right-click on the Dialog folder and choose Insert Dialog
  4. Right-click the newly added dialog resource and choose Add Class
  5. Give the new class a name and choose the base class as CDHtmlDialog
  6. Click the Finish button.
The IDE should AV at this point. Modify the default.js file as outlined in the Resolution section and you should be able to create the dialog class without error.


↑ Back to the top


Keywords: kb

↑ Back to the top

Article Info
Article ID : 2276854
Revision : 1
Created on : 1/7/2017
Published on : 8/24/2010
Exists online : False
Views : 99