使用“VisualStudio.DTE.10.0"创建解决方案并添加项目 [英] Create a solution and add a project using "VisualStudio.DTE.10.0"

查看:37
本文介绍了使用“VisualStudio.DTE.10.0"创建解决方案并添加项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个 VS2010 解决方案并从独立应用程序(不是加载项)添加项目.我可以创建VS2010的实例,但是我无法确定如何正确创建项目......我只能找到如何使用EnvDTE80对象创建项目的示例,后来导致异常,因为项目文件是较早的格式,需要升级.我有这个:

I'm trying to create a VS2010 solution and add a project from a stand-alone app (not an add-in). I can create an instance of VS2010, but I'm not able to determine how to create a project properly...I can only find an example of how to create a project using the EnvDTE80 object, which later causes an exception because the project file is in an earlier format and needs to be upgraded. I have this:

EnvDTE80.DTE2 dte2;
object obj;
System.Type t;
t = System.Type.GetTypeFromProgID("VisualStudio.DTE.10.0", true);
obj = System.Activator.CreateInstance(t, true);
dte2 = (EnvDTE80.DTE2)obj;

我正在寻找的东西相当于EnvDTE100.DTE2",但不知道如何到达那里.

What I'm looking for is the equivalent of something like "EnvDTE100.DTE2" but don't know how to get there.

谢谢

推荐答案

您不必通过 DTE 对象.对对象的处理解决方案4不同你应该这样做

You do not have to go via DTE object. The treatment to the object solution4 it's different you should do this

Type latestSolution = Type.GetTypeFromProgID("VisualStudio.10.0", true);
EnvDTE100.Solution4 vsSolution = (EnvDTE100.Solution4)Activator.CreateInstance(latestSolution, true);

这篇关于使用“VisualStudio.DTE.10.0"创建解决方案并添加项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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