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).
MORE INFORMATION
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.
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("testingVar1") = "value of testing var1" proj.Globals.VariablePersists("testingVar1") = True MsgBox(proj.Globals.VariableValue("testingVar1")) 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
- Close the Macro IDE window.
- On the Tools menu, click Macros and then click Macro Explorer (or press ALT+F8 to open the Macro Explorer).
- Expand MyMacros and then expand Module1.
- To set the global variable, double-click SetGlobals .
- To show the value of the global variable, double-click showAllGlobals. NOTE: At this point, the global variable should be "value of testing var1".
- Close the Win32 project.
- Open the Win32 project again.
- Open the Macro Explorer.
- Double-click showAllGlobals to see whether the change to the global variable was saved. Result: You receive the error message: Expected: When you change the project globals and close the solution, you are prompted to save the project.
Keywords: kbbug kbnofix KB315484