问题描述
我打开使用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的环境中。然后把你的手在运行通过运行对象表(腐烂)。
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实例。
这篇关于Visual Studio 2010的自动化和环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!