1

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?

SWeko
  • 30,434
  • 10
  • 71
  • 106
  • What does the VS2008 documentation tell you about this? – Lazarus Feb 10 '10 at 12:42
  • 1
    Is parsing the .sln file an option? Seems like it'd be much easier. – Nick Craver Feb 10 '10 at 12:44
  • The documentation claims that this should work :) And I would like to avoid parsing the .sln file directly because that will void the 2005 code I have (also introduce a batch of new parsing problems I guess) – SWeko Feb 10 '10 at 12:50
  • Is VS 2008 normally starting (usually during first start some long-running initialization takes place)? The error code means that the application is busy. This error however might also be triggered by anti-virus software (see http://support.microsoft.com/kb/246018). – Dirk Vollmar Feb 10 '10 at 12:53
  • I'd go for parsing the sln file in the long run Im pretty sure it's faster (dev. time wise) that any other approach. It's a very simple format and shouldn't take much more than half a day for both 2005 and 2008 – Rune FS Feb 10 '10 at 13:48
  • Agreed, that does seem less prone to weird errors. Btw, found this - http://msdn.microsoft.com/en-us/library/ms228772%28VS.80%29.aspx that might explain the COM errors. – SWeko Feb 10 '10 at 14:33

2 Answers2

1

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.

Community
  • 1
  • 1
Nick Craver
  • 623,446
  • 136
  • 1,297
  • 1,155
  • does not work with the antivirus turned off, too And if I try DTE2 _dte = (DTE2) Microsoft.VisualBasic.Interaction.CreateObject("VisualStudio.DTE.9.0", ""); I get a "Cannot create ActiveX component." error. – SWeko Feb 10 '10 at 13:35
1

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.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • Nope, fails even when not debugging... And, yes, I kinda try to lift myself by pulling on my shoestrings. – SWeko Feb 10 '10 at 14:29
  • I had no problem running the same code. I can't think of a reason why you would, other than adding the wrong reference. I did use envdte.dll from the VS2008 install directory. – Hans Passant Feb 10 '10 at 16:01