Microsoft KB Archive/810304

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

Article ID: 810304

Article Last Modified on 5/9/2007

-

APPLIES TO


 * Microsoft Visual C++ .NET 2002 Standard Edition
 * Microsoft Visual Studio .NET 2002 Enterprise Architect
 * Microsoft Visual Studio .NET 2002 Enterprise Developer
 * 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 &quot;0x02cadfa8&quot; referenced memory at &quot;0xc0000000&quot;. The memory could not be &quot;written&quot;.



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 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(&quot;NUM_LOOPS&quot;, 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(&quot;NUM_LOOPS&quot;, 5); ...   }    ... }  For more information about the VCWizCtl object and its AddSymbol method, see the &quot;References&quot; 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

