Read Current Project Settings from a Visual Studio 2010 Add-In?

[亡魂溺海] 提交于 2019-12-13 03:55:40

问题


I'm writing a visual studio Add-In that will activate when the debugger is launched. The Add-In needs to check the Project settings of the currently running project and read specifically the check boxes on the Web tab at the bottom of that tab where it says Debuggers. I would like to read the project settings each time and determine which check boxes are checked everytime the debugger is launched the "ASP.NET" "Native Code" "SQL Server" "Silverlight" "Enable Edit and Continue" checkboxes.

I've gone through the examples in the SDK haven't found anything that specifically read the project settings. If anybody could point me in the right direction that would be helpful.


回答1:


It turns out that the answer is easier than I thought. The Web Configuration in the Web Tab of the Project Properties window is only available when working with a Web Project. A Web Project is an Extender. To access the Extenders in a project you would access it with the below code.

 Microsoft.VisualStudio.Web.Application.WAProjectExtender extend = null;

 foreach ( object item in ( Array )project.ExtenderNames )
 {
     extend = project.Extender[ item.ToString( ) ] as Microsoft.VisualStudio.Web.Application.WAProjectExtender;
     if ( extend != null )
     {
         return extend.SilverlightDebugging;
     }
 }

The Class Microsoft.VisualStudio.Web.Application.WAProjectExtender contains all the properties in nicely named easy to access properties. So finding out if SilverlightDebugging is checked is as simple as checking extend.SilverlightDebugging. I wrote an Extension to the Application object that would give me the current project then using that finding the Extender which casts nicely to WAProjectExtender. This class is found inside of the IDE specific assembly located on my system at E:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Microsoft.VisualStudio.Web.Application.dll



来源:https://stackoverflow.com/questions/5703895/read-current-project-settings-from-a-visual-studio-2010-add-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!