Microsoft KB Archive/315484

From BetaArchive Wiki
Knowledge Base


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

  1. Start Microsoft Visual Studio .NET.
  2. On the File menu, click New, and then click Project.
  3. Click Visual C++ Projects under Project Types, and then click Win32 Project under Templates.
  4. Type the project name, and then click OK.
  5. On the Tools menu, click Macros and then click Macro IDE (or press ALT+F11) to display the Macro integrated development environment (IDE) window.
  6. Expand MyMacros, and then double-click Module1 to edit the macro.
  7. 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
    
                        
  8. Close the Macro IDE window.
  9. On the Tools menu, click Macros and then click Macro Explorer (or press ALT+F8 to open the Macro Explorer).
  10. Expand MyMacros and then expand Module1.
  11. To set the global variable, double-click SetGlobals .
  12. To show the value of the global variable, double-click showAllGlobals. NOTE: At this point, the global variable should be "value of testing var1".

  13. Close the Win32 project.
  14. Open the Win32 project again.
  15. Open the Macro Explorer.
  16. 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.


Keywords: kbbug kbnofix KB315484