BUG: Visual C++ .NET Custom Wizard [!loop=n] directive crashes Visual Studio .NET (810304)



The information in this article applies to:

  • Microsoft Visual C++ .NET (2002)
  • Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2002), Academic Edition

SYMPTOMS

While creating a new project, the Visual Studio .NET integrated development environment (IDE) stops responding and eventually crashes. You receive the following application error message for Devenv.exe:
The instruction at "0x02cadfa8" referenced memory at "0xc0000000". The memory could not be "written".

CAUSE

The Visual Studio .NET wizard engine, VsWizard.dll, processes a project template file (such as Templates.inf or a template that is specified in Templates.inf) that contains the directive
[!loop = n]
...
[!endloop]
where n is a literal numeric value. The engine does not recognize the numeric value.

Notice

See bug VisualStudio7:575018 in the VisualStudio7 database for details.

WORKAROUND

To work around this issue, modify the template file directive to use the alternative syntax
[!loop = symbol]
...
[!endloop]
where symbol is a template symbol that is defined with a numeric value.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Wizards that are based on the Visual Studio .NET wizard engine, such as those produced by the Visual C++ .NET Custom Wizard, recognize a template directive loop as follows:.
[!loop = n]
...
[!endloop]
When n is a literal number, the directive causes Visual Studio .NET to crash. The crash occurs during project or code generation when the directive is encountered in a template file.

How to Specify the Loop Counter

As an alternative method to specify the loop counter, define a symbol with a numeric value and then use this symbol in the loop directive. The numeric value indicates the number of loops the wizard executes.

The following examples provide three ways to define the symbol named NUM_LOOPS with a numeric value 5. The numeric value 5 is the number of loops to be executed.
  • In the OnFinish function located in the Default.htm file, use the AddSymbol function to add a symbol with an appropriate value:
    function OnFinish(document)
    	{
    		window.external.AddSymbol("NUM_LOOPS", 5);
    		OnWizFinish(document);
    	}
  • In the OnFinish function located in the Default.js file, use the AddSymbol function to add a symbol with an appropriate value:
    function OnFinish(selProj, selObj)
    {
    	try
    	{
    		var strProjectPath = wizard.FindSymbol('PROJECT_PATH');
    		var strProjectName = wizard.FindSymbol('PROJECT_NAME');
    
    		wizard.AddSymbol("NUM_LOOPS", 5);
    		...
    	}
    	...
    }
    For more information about the VCWizCtl object and its AddSymbol method, see the "References" section.
  • In the template file (such as Templates.inf or a template specified in Templates.inf), create a symbol using the syntax [!symbol = n], where symbol is the symbol name used to control the loop and n is the number of loops to process:
    [!NUM_LOOPS = 5]
    
    
    Note: The directive [!symbol = n] is currently undocumented.

The loop directive can now be specified with the NUM_LOOPS symbol, instead of a numeric value:
[!loop = NUM_LOOPS]
...
[!endloop]
For more information about this syntax, click the following article number to view the article in the Microsoft Knowledge Base:

810455 How to migrate a Visual C++ 6.0 custom AppWizard to a Visual C++ .NET custom wizard

REFERENCES

For more information about template directives, see the following MSDN Web site:http://msdn.microsoft.com/library/en-us/vccore/html/vcoriTemplateDirectives.asp

For more information about Visual C++ Wizard Model in Visual Studio .NET, see the following MSDN Web site: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcext/html/vcorivisualcwizardmodel.asp

Modification Type:MinorLast Reviewed:1/5/2006
Keywords:kbvs2002sp1sweep kbBug kbExtensibility kbwizard kbide kbCustomWizard kbCodeGen KB810304 kbAudDeveloper kbAudITPRO kbAudOEM