locked
Loading a solution into Visual Studio instance RRS feed

  • Question

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

    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.

    Although the code is not a Visual Studio extension as such, I'm asking in this forum because the techniques I need are similar (using an EnvDTE80.DTE2 application object, for example), and I don't see a more appropriate forum.

    Wednesday, July 28, 2010 3:10 AM

Answers

  • Discovered that I could do this:

    let soln2 = dte2.Solution :?> EnvDTE80.Solution2 in
    let _ = soln2.Open(solutionFile) in
    ...
    That works, although it's kind of bizarre.

    • Marked as answer by psteckler Wednesday, July 28, 2010 4:13 AM
    Wednesday, July 28, 2010 4:13 AM

All replies

  • You can open an existing solution via the dte2.Solution.Open method.

    Sincerely,


    Ed Dore
    Wednesday, July 28, 2010 3:58 AM
  • Discovered that I could do this:

    let soln2 = dte2.Solution :?> EnvDTE80.Solution2 in
    let _ = soln2.Open(solutionFile) in
    ...
    That works, although it's kind of bizarre.

    • Marked as answer by psteckler Wednesday, July 28, 2010 4:13 AM
    Wednesday, July 28, 2010 4:13 AM