实例化 VisualStudio 2008
我正在尝试获取指定 VS2008 解决方案中所有项目的列表。 (这是一个独立的控制台应用程序,它不是 Visual Studio 加载项)
我的代码适用于 VS2005 解决方案,但在尝试使用 VS2008 对象时遇到各种丑陋的 COM 错误。
我的意思是: This:
Type _visualStudioType = Type.GetTypeFromProgID("VisualStudio.DTE.8.0");
DTE _dte = Activator.CreateInstance(_visualStudioType) as DTE;
有效,而 this:
Type _visualStudioType = Type.GetTypeFromProgID("VisualStudio.DTE.9.0");
DTE _dte = Activator.CreateInstance(_visualStudioType) as DTE;
无效(当前抛出 COM 错误 8001010a)
我在注册表中注册了两个相关的类,并且引用了所有适当的程序集。
编辑:我将进行 .sln 文件的基本解析,即使我必须进行一些重写,因为文本操作必然会在没有所有讨厌的互操作内容的情况下工作。 但是,我似乎找不到 .sln 格式的描述,有资源吗?
I'm trying to get a list of all projects within a specified VS2008 solution. (this is a stand-alone console app, it is not a Visual Studio add-in)
My code works with VS2005 solutions, but I get all sorts of ugly COM errors trying to use the VS2008 object.
What I mean is:
This:
Type _visualStudioType = Type.GetTypeFromProgID("VisualStudio.DTE.8.0");
DTE _dte = Activator.CreateInstance(_visualStudioType) as DTE;
works and this:
Type _visualStudioType = Type.GetTypeFromProgID("VisualStudio.DTE.9.0");
DTE _dte = Activator.CreateInstance(_visualStudioType) as DTE;
doesn't (currently throws COM error 8001010a)
I have both relevant classes registered in the registry, and all appropriate assemblies are referenced.
Edit: I'll go with basic parsing of the .sln file, even if I have to do a bit of rewriting, as text manipulation is bound to work without all the nasty interop stuff.
However, I can't seem to find a description of the .sln format, any resources?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能想看看这个: 用于解析 Visual Studio 解决方案的库文件? 如果直接解析 .sln 是您唯一的选择。
至于您当前的问题, 其他一些人也遇到了您的问题。 KB246018 表示检查您的防病毒软件是主要原因(示例是单词,但同样适用于VS)。尝试完全排除 VS 目录。
You may want to look at this: Library for parsing Visual Studio Solution files? If parsing the .sln directly turns out to be your only option.
As to your current problem, some other people have had your issue. The KB246018 says check out your antivirus as the leading cause (example is word, but same applies to VS). Try excluding the VS directory entirely.
您收到 RPC 错误:“服务器正忙”。这可能是因为 Visual Studio 实际上很忙,正在调试控制台模式程序。如果无法使用 Console.WriteLine() 语句进行调试,请尝试另一个调试器。 Windows SDK 具有 clrdbg.exe 和 mdbg.exe 调试器。 .NET 2.0 SDK 有一个 GUI 调试器 iirc。
You are getting an RPC error: "server is busy". That might be because Visual Studio is actually busy, debugging your console mode program. Short from debugging with Console.WriteLine() statements, try another debugger. The Windows SDK has the clrdbg.exe and mdbg.exe debuggers. The .NET 2.0 SDK had a GUI debugger iirc.