Instantiating VisualStudio 2008
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 resour开发者_JAVA百科ces?
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.
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.
精彩评论