Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 308603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:39:56+00:00 2026-05-12T07:39:56+00:00

I would like to open into memory an existing .sln file. Example of a

  • 0

I would like to open into memory an existing .sln file.

Example of a non-working method:

private Solution2 OpenSolution(string filePath)
{
    Solution2 sln;
    sln.Open(filePath);
    return sln;
}

If I have an instance of Solution2 then i can call the method Open; but how can i get an instance of Solution2?

My goal is then to get the adequate project and read some of its settings… but that’s easy having access to the solution.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T07:39:56+00:00Added an answer on May 12, 2026 at 7:39 am

    You can programmatically create a hidden instance of Visual Studio, and then use it to manipulate your solution. This example will list out all the projects that live in the given solution.

    using System;
    using System.Runtime.InteropServices;
    using EnvDTE;
    using EnvDTE80;
    
    namespace so_sln
    {
       class Program
       {
          [STAThread]
          static void Main(string[] args)
          {
             System.Type t = System.Type.GetTypeFromProgID("VisualStudio.DTE.8.0", true);
             DTE2 dte = (EnvDTE80.DTE2)System.Activator.CreateInstance(t, true);
    
             // See http://msdn.microsoft.com/en-us/library/ms228772.aspx for the
             // code for MessageFilter - just paste it into the so_sln namespace.
             MessageFilter.Register();
    
             dte.Solution.Open(@"C:\path\to\my.sln");
             foreach (Project project in dte.Solution.Projects)
             {
                Console.WriteLine(project.Name);
             }
    
             dte.Quit();
          }
       }
    
       public class MessageFilter : IOleMessageFilter
       {
          ... Continues at http://msdn.microsoft.com/en-us/library/ms228772.aspx
    

    (The nonsense with STAThread and MessageFilter is “due to threading contention issues between external multi-threaded applications and Visual Studio”, whatever that means. Pasting in the code from http://msdn.microsoft.com/en-us/library/ms228772.aspx makes it work.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to open a small video file and map every frames in
I would like to read a (fairly big) log file into a MATLAB string
Our SEO team would like to open up our main dynamic search results page
I would like to know if I can open 2 different diagrams using MS
I would like to contribute to an open-source Windows Mobile project, but it's being
I would like to create an iPhone app that can open the google maps
I would like to know the simplest and most effective way to open and
I would like to use create a rails route for a user's open id.
Is there any open source Object Database available? I would like to have a
This is a bit of an open question but I would really like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.