你如何从一个VSPackage的当前解决方案目录? [英] How do you get the current solution directory from a VSPackage?

查看:412
本文介绍了你如何从一个VSPackage的当前解决方案目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是你将如何从加载项获得当前解决方案目录:

Following is how you would get the current solution directory from an add-in:

_applicationObject = (DTE2)application;  // retrieved from OnConnection method
string solutionDir = System.IO.Path.GetDirectoryName(_applicationObject.Solution.FullName);

您将如何通过VSPackage的做到这一点?

How would you do this via a VSPackage?

我迁移一个Visual Studio加载到VSPackage的因为我打算添加需要在IDE中深度整合了一些用户控件。

I'm migrating a visual studio add-in to a VSPackage as I'm intending to add some user controls that require a deeper integration with the IDE.

我发现加载项的相对优点VS集成软件包,如一些很好的参考:
http://nayyeri.net/visual-studio-addin-vs-integration-package-part-1

I found some good references on the relative merits of add-ins vs integration packages such as: http://nayyeri.net/visual-studio-addin-vs-integration-package-part-1

和一些很好的教程上MSDN上的VSPackage如:
http://msdn.microsoft.com/en-us/库/ cc138589.aspx

And some good tutorials on msdn on VSPackages such as: http://msdn.microsoft.com/en-us/library/cc138589.aspx

我没有在加载项(如何上级界面找到了一个很好的参考,但(MSDN或其他方式)如DTE)映射到的VSPackage较低水平接口。

I haven't found a good reference yet (on msdn or otherwise) on how the higher level interfaces in add-ins (such as DTE) map to lower level interfaces in VSPackages.

任何好​​的引用了那里帮助与外接接口VSPackage的接口一般映射?

Any good references out there to help with general mapping from add-in interfaces to VSPackage interfaces?

推荐答案

我找到了答案的具体问题。该VisualStudio.DTE对象可以通过 GetService的()方法来检索如下:

I found the answer to the specific question. The VisualStudio.DTE object can be retrieved via the GetService() method as follows:

// Get an instance of the currently running Visual Studio IDE
DTE dte = (DTE)GetService(typeof(DTE));
string solutionDir = System.IO.Path.GetDirectoryName(dte.Solution.FullName);

这篇关于你如何从一个VSPackage的当前解决方案目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆