Microsoft KB Archive/315484

= FIX: You Are Not Prompted to Save Global Variable Changes in Visual C++ Project =

Article ID: 315484

Article Last Modified on 1/17/2004

-

APPLIES TO


 * Microsoft Visual C++ .NET 2002 Standard Edition

-



This article was previously published under Q315484



SYMPTOMS
If you change the global variables in a Visual C++ project and then close the project, you may not receive a dialog box that prompts you to save the global variable changes that you made to the project. Even if you click SaveAll, the global variables are not saved.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug was corrected in Microsoft Visual C++ .NET (2003).



Steps to Reproduce the Behavior
 Start Microsoft Visual Studio .NET. On the File menu, click New, and then click Project. Click Visual C++ Projects under Project Types, and then click Win32 Project under Templates. Type the project name, and then click OK. On the Tools menu, click Macros and then click Macro IDE (or press ALT+F11) to display the Macro integrated development environment (IDE) window. Expand MyMacros, and then double-click Module1 to edit the macro.</li>  Copy and paste the following code in Module1. The final code should appear as follows: Imports EnvDTE Imports System.Diagnostics

Public Module Module1 Sub SetGlobals Dim proj As Project proj = DTE.ActiveSolutionProjects(0) proj.Globals.VariableValue(&quot;testingVar1&quot;) = &quot;value of testing var1&quot; proj.Globals.VariablePersists(&quot;testingVar1&quot;) = True MsgBox(proj.Globals.VariableValue(&quot;testingVar1&quot;)) End Sub

Sub showAllGlobals Dim proj As Project proj = DTE.ActiveSolutionProjects(0) Dim i As Integer For i = 0 To proj.Globals.VariableNames.length - 1 MsgBox(proj.Globals.VariableNames(i)) MsgBox(proj.Globals.VariableValue(proj.Globals.VariableNames(i))) Next End Sub End Module

</li> Close the Macro IDE window.</li> On the Tools menu, click Macros and then click Macro Explorer (or press ALT+F8 to open the Macro Explorer).</li> Expand MyMacros and then expand Module1.</li> To set the global variable, double-click SetGlobals .</li> To show the value of the global variable, double-click showAllGlobals. NOTE: At this point, the global variable should be &quot;value of testing var1&quot;.

</li> Close the Win32 project.</li> Open the Win32 project again.</li> Open the Macro Explorer.</li> Double-click showAllGlobals to see whether the change to the global variable was saved. Result: You receive the error message:

object variable or with block variable not set

Expected: When you change the project globals and close the solution, you are prompted to save the project.</li></ol>

Keywords: kbbug kbnofix KB315484

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.