Pablo Galiano : Persisting user information in Visual Studio

Subscriptions

<November 2008>
SuMoTuWeThFrSa
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

News

Subscribe to Pablo Galiano by Email

Post Categories

Persisting user information in Visual Studio

Visual Studio offers a way to persist user information between sessions. This is done by using the Globals object located on the EnvDTE assembly.
The Globals object allows you to store, retrieve, enumerate and persist user information. So the next time the IDE is open this information is restored.
We can persist information at three different levels:

  • VS or IDE
     
    The information is stored in C:\Documents and Settings\<username>\Application Data\Microsoft\Visual Studio\extglobal.dat. These values are persisted each time VS is closed or a Save All operation occurs.

Snippet:

            DTE.Globals["PropertyName"] = value;
            DTE.Globals.set_VariablePersists("PropertyName", true);

  • Solution

The information is stored in the .sln file. These values are persisted when the solution file is saved.

Snippet:

            solution.Globals["PropertyName"] = value;
            solution.Globals.set_VariablePersists("PropertyName", true);

  • Project

The information is stored in the project file. These values are persisted anytime a project is saved.

Snippet:

            project.Globals["PropertyName"] = value;
            project.Globals.set_VariablePersists("PropertyName", true);

One important thing is that Values to be stored must be strings, they cannot be objects or structures because these files are xml files.


Pablo

posted on Tuesday, January 09, 2007 6:18 PM by pga

# re: Persisting user information in Visual Studio @ Thursday, November 15, 2007 8:34 AM

BTW: Do not use periods in the variable names. VS2005 started throwing exceptions despite the fact that prior versions of VS allowed them.

Scott Willeke