[英]EnvDTE Visual Studio 2013 : get the progID?
I am trying to create a Visual Studio instance using : 我正在尝试使用创建Visual Studio实例:
EnvDTE80.DTE2 dte2;
dte2 = (EnvDTE80.DTE2)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.12.0");
And I am always having the exception "Invalid Class String" so I assume that the problem is "VisualStudio.DTE.12.0". 而且我总是遇到“ Invalid Class String”异常,因此我认为问题是“ VisualStudio.DTE.12.0”。 But I am working on Visual Studio 2013 12.0.30501, I also tried to put only "VisualStudio.DTE" to get the most recent version, and same exception.
但是我正在使用Visual Studio 2013 12.0.30501,我还尝试仅放置“ VisualStudio.DTE”以获取最新版本,并且具有相同的例外。
Also, I tried the other way : 另外,我尝试了另一种方式:
Type t = Type.GetTypeFromProgID("VisualStudio.DTE.12.0", true);
dte2 = (EnvDTE80.DTE2)System.Activator.CreateInstance(t, true);
The problem is still there, I am running a bit out of idea... Is it really an invalid string error ? 问题仍然存在,我有点想法不对...真的是无效的字符串错误吗?
If you are using Visual Studio 2013 Express this works to fix it: 如果您使用的是Visual Studio 2013 Express,则可以对其进行修复:
Type t = Type.GetTypeFromProgID("WDExpress.DTE.12.0", true);
var x = (EnvDTE80.DTE2)System.Activator.CreateInstance(t, true);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.