开发者

Visual Studio Extensibility Package not looking at correct project

I have created a new VS 2010 extensibility package. So far, all I want to do is have the user press a button and fill a listview with the entire contents of the solution. I have the following code:

EnvDTE80.DTE2 dte = (EnvDTE80.DTE2)System.Runtime.InteropServices.Marshal.
    GetActiveObject("Vi开发者_开发知识库sualStudio.DTE.10.0");

foreach (Project project in dte.Solution.Projects)
{
    foreach(ProjectItem pi in project.ProjectItems)
    {
         listView1.Items.Add(pi.Name.ToString());
    }
}

This does seem to work, however, it populates the list with the contents of the solution with the package in it and not the experimental instance that is launched when this is run. Am I instantiating the reference wrongly?


GetActiveObject method returns first process instance of DTE, not caller DTE. (in Visual Studio SDK 2010 project on Visual Studio 2010, type F5 to execure experimental hive may fail)

Look at here and here for more details...


No - you need to use ProjectItem.SubProject to get to what you want... depending on the solution structure some recursion could be needed... for some sample code doing nicely all this see http://www.wwwlicious.com/2011/03/envdte-getting-all-projects.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜