Visual Studio 2010的自动化和环境变量 [英] Visual Studio 2010 automation and environment variables

查看:301
本文介绍了Visual Studio 2010的自动化和环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打开使用C#和Visual Studio 2010的自动化解决方案,VS2010。我打开的解决方案是这样的:

I am opening VS2010 solutions using C# and VS2010 automation. I open the solutions like this:

Type type = Type.GetTypeFromProgID("VisualStudio.DTE.10.0", true);
Object comObject = Activator.CreateInstance(type);
...
sol.Open(solution_full_path);

我遇到的问题是,当我创建 VisualStudio.DTE.10.0 对象的实例,它会启动 devenv.exe的的winlogon.exe 这完全看到不同的环境比我的申请。一些环境变量是解决一些路径在项目设置非常重要的。

The problem I am having is that when I create the instance of the VisualStudio.DTE.10.0 object, it starts the devenv.exe process from winlogon.exe which sees completely different environment than my application. Some of the environment variables are important for resolving some paths set in projects.

有什么我可以如何影响 devenv.exe的进程的环境变量?有什么办法,我可以如何使用VS2010自动化接口注入环境/属性?

Is there any how I can influence the environment variables of the devenv.exe process? Is there any way how I could inject environment/properties using the VS2010 automation interfaces?

推荐答案

是否有可能自行启动devenv的环境中。然后把你的手在运行 Visual Studio的实例通过运行对象表(腐烂)。

Is it possible to start devenv by yourself inside your environment. Then get your hands on the running Visual Studio Instance via the running object table (ROT).

// Get an instance of the currently running Visual Studio IDE.
EnvDTE80.DTE2 dte2;
dte2 = (EnvDTE80.DTE2)System.Runtime.InteropServices.Marshal.
GetActiveObject("VisualStudio.DTE.10.0");

如果你有多个正在运行的实例,VS但是这也容易,你将得到的问题。你可以得到你的手href=\"http://msdn.microsoft.com/en-us/library/ms228755.aspx\" rel=\"nofollow\">一个特定VS 的情况下,你只需要知道你的自我的过程中ID启动VS实例。

You will get problems if you have more than one running VS instance but this also an easy one. You can get your hands on a specific VS instance where you only need to know the process id of your self started VS instance.

Visual Studio中也注册一个ProgID作为ROT​​项目绰号。
  进程id是一个由DTE进程的名称和进程ID。
  因此,例如,对象的ROT条目可能是
  !VisualStudio.DTE.10.0:1234。其中,1234是进程ID

Visual Studio also registers a ProgID as an item moniker in the ROT. The ProgID is comprised of the name and process ID of the DTE process. So, for example, the object's ROT entry might be "!VisualStudio.DTE.10.0:1234," where 1234 is the process ID.

这篇关于Visual Studio 2010的自动化和环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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