Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / IDE / March 2008

Tip: Looking for answers? Try searching our database.

Persist global to solution?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bob Altman - 26 Mar 2008 20:30 GMT
Hi all,

I am writing an add-in that wants to persist some data to the solution file
using DTE.Solution.Globals, but I can't get it to work.  Here is the code I'm
using:

 Public Sub OnConnection(...) _
 Implements IDTExtensibility2.OnConnection
   m_appObject = CType(application, DTE2)
   m_appObject.Solution.Globals.VariableValue("MyTest") = "Hello Bob"

The value I assign to MyTest remains until I close the solution, at which time
it goes away.  According to the documentation, simply setting the VariableValue
property should dirty the solution file, but that's not happening.

If I examine appObject.Solution.Globals.VariablePersists("MyTest")  immediately
after setting the variable value it returns False.  So I added this line of code
after the last line above:

   m_appObject.Solution.Globals.VariablePersists("MyTest") = True

That didn't help.  I can't convince the Globals object to persist its value to
the solution file.

TIA - Bob
Wen Yuan Wang [MSFT] - 27 Mar 2008 11:27 GMT
Hello Bob,

According to your description, you found that the variable doesn't persist
after you close the solution, correct? If I misunderstood anything here,
please don't hesitate to correct me. Thanks.

After you set the VariablePersists("MyTest") to true, VS will drop a line
into your solution file.  This data will be loaded when your solution
opened in VS.
Such as below:
GlobalSection(ExtensibilityGlobals) = postSolution
    MyTest = Hello Bob
EndGlobalSection

I believe you closed the solution but did not choose to save the modified
files. This will result the data isn't written into that file.

Hope this helps. Please feel free to let me know if there is anything
unclear. We are glad to assist you.
Have a great day,
Best regards,
Wen Yuan

Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Bob Altman - 27 Mar 2008 18:28 GMT
> According to your description, you found that the variable doesn't persist
> after you close the solution, correct?

Yes, that is correct.

> After you set the VariablePersists("MyTest") to true, VS will drop a line
> into your solution file.  This data will be loaded when your solution
[quoted text clipped - 3 lines]
> MyTest = Hello Bob
> EndGlobalSection

Yes, that is what I expect to happen

> I believe you closed the solution but did not choose to save the modified
> files. This will result the data isn't written into that file.

No, the solution file is not dirtied by the IDE.  When I close the IDE I am not
prompted to save any files.  Even if I explicitly Save All then I don't see the
changes in the solution file.
Wen Yuan Wang [MSFT] - 28 Mar 2008 10:14 GMT
Hello Bob,
Thanks for your reply.

This behavior is really strange. VS IDE should dirty sln file, after you
specified VariablePersists("MyTest") to true. It really works fine on my
side.
We need to perform further research. Is it possible for you to send me a
simple project to reproduce the issue on my side? My email address is
v-wywang@microsoft.com.
If you have any more concern, please feel free to let us know. It's my
pleasure to assist you.

Have a great day,
Best regards,
Wen Yuan

Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Bob Altman - 31 Mar 2008 21:33 GMT
It turned out that I stumbled across an undocumented "product limitation".
Here, for the edification and amusement of anyone else who may come along
looking for this information, is what I've discovered:

I'm writing a "solution add-in".  That's a standard issue add-in that contains
some code in the OnConnect routine that updates a solution (.sln) file so that
the add-in is loaded whenever the solution is loaded.  It turns out that when a
solution is loaded and its associated add-in is loaded, the Globals object can
not persist data back to the solution file in the OnConnect routine (connectMode
= ext_cm_Solution).

Bob

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.