在 VS Package 项目中获取 dte2 或 TeamFoundationServerExt 对象? [英] Getting the dte2 or TeamFoundationServerExt object in a VS Package project?

查看:22
本文介绍了在 VS Package 项目中获取 dte2 或 TeamFoundationServerExt 对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个 Visual Studio Package 项目.这个项目需要连接到我们的 TFS.要读取当前连接,我需要 TeamFoundationServerExt 对象,我应该能够从 dte2 对象中获取该对象.

I am working on a Visual Studio Package project. This project needs a connection to our TFS. To read the current connection, I would need the TeamFoundationServerExt object, which I should be able to get from the dte2 object.

现在我发现了数百个示例,其中大部分都使用了_application"变量,该变量似乎会自动填充,但当然不适用于Visual Studio Package"项目类型.

Now I found hundreds of examples and most of them are working with an "_application" variable, which seems to get automatically filled, but of course not for the "Visual Studio Package" project type.

如何获取当前运行的VS2010的TeamFoundationServerExt对象?

How can I get the TeamFoundationServerExt object of the currently running VS2010?

推荐答案

您应该能够从 VSPackage 执行以下操作以获取当前 DTE 对象:

You should be able to do the following from a VSPackage to get the current DTE object:

DTE2 dte = ServiceProvider.GlobalProvider.GetService(typeof(SDTE)) as DTE2;

您可能还需要检查您的包裹是否不在 一个僵尸"(即启动)状态,以防您从 GetService 调用中获得空值.

You may also need to check that your package isn't in a "Zombie" (i.e. starting up) state in case you're getting null from the GetService call.

这篇关于在 VS Package 项目中获取 dte2 或 TeamFoundationServerExt 对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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