Not sure if this will help you or not. Strange thing is, first time I ran this code, g_test didn't seem to exist. Then after setting it, it did exist. I don't think the first time around it "sees" the g_test variable. But then it seems to create one.

Haven't ever message with this stuff before, so I don't know what's going on.
VB Code:
  1. Public g_test As Integer = 9  ' This variable is 'globally' available???
  2.  
  3.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  4.         Dim DTE As EnvDTE.DTE
  5.         DTE = System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE")
  6.         'MessageBox.Show(DTE.Solution.Globals.VariableValue("g_test"))
  7.         MessageBox.Show(DTE.Solution.Globals.VariableExists("g_test"))
  8.         DTE.Solution.Globals.VariableValue("g_test") = 42
  9.         MessageBox.Show(DTE.Solution.Globals.VariableValue("g_test"))
  10.     End Sub