[英]Visual Studio Extensibility Package not looking at correct project
I have created a new VS 2010 extensibility package. 我创建了一个新的VS 2010可扩展性包。 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("VisualStudio.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. GetActiveObject方法返回DTE的第一个流程实例,而不是调用者DTE。 (in Visual Studio SDK 2010 project on Visual Studio 2010, type F5 to execure experimental hive may fail) (在Visual Studio 2010上的Visual Studio SDK 2010项目中,键入F5以执行实验配置单元可能会失败)
Look at here and here for more details... 请看这里和这里了解更多详情......
不 - 你需要使用ProjectItem.SubProject
来获得你想要的东西......取决于解决方案结构,可能需要一些递归...对于一些示例代码做得很好所有这些看到http://www.wwwlicious.com/ 2011/03 / envdte-越来越-ALL-projects.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.