views:

13

answers:

1

I have an F# program that creates an instance of Visual Studio:

  let vsTy = Type.GetTypeFromProgID("VisualStudio.DTE.10.0") in
  let dte2 = Activator.CreateInstance(vsTy,true) :?> EnvDTE80.DTE2 in
  ...

That works well; I can probe all kinds of info about the running instance of Visual Studio.

But I can't determine how to load a solution into the instance of Visual Studio. I've tried dte2.ItemOperations.OpenFile(). I've also tried dte2.ExecuteCommand("File.OpenProject"), which works, but requires the user to select from a file dialog -- I want something that works from code alone.

A: 

Here's how to do it: let soln2 = dte2.Solution :?> EnvDTE80.Solution2 in let _ = soln2.Open(solutionFile) in ... Bizarre, because dte2.Solution isn't a solution at all.

Paul Steckler