Instantiating a SolutionClass - COM Error

02 Oct 2005

I'm trying to address the solution class in EnvDTE.dll with this code:

SolutionClass MySolution = new SolutionClass();

Sensible stuff? Apparently not - I'm getting some mad COM error, specifically "COM object with clsid {B35CAA8C-77DE-4AB3-8E5A-F038E3FC6056} is either not valid or not registered". Quite how Microsoft expect me to know what the hell this means, I do not know.

Thanks to the power of Google, I found the solution. In .NET 1.1 you can instantiate the SolutionClass like this:

System.Type type = System.Type.GetTypeFromProgID("VisualStudio.Solution.7.1");
Object o = System.Activator.CreateInstance(type, true);

EnvDTE.Solution MySolution = (EnvDTE.Solution)o;


Feedback or questions on this post? Create an issue on GitHub.