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 8294991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T14:25:39+00:00 2026-06-08T14:25:39+00:00

when I do: // Get an instance of the currently running Visual Studio IDE.

  • 0

when I do:

// Get an instance of the currently running Visual Studio IDE.
EnvDTE80.DTE2 dte2;
dte2 = (EnvDTE80.DTE2)System.Runtime.InteropServices.Marshal.
GetActiveObject("VisualStudio.DTE.10.0");

var solution = dte2.Solution; // get solution

Console.WriteLine(solution.FullName);  // prints the name of the solution where this code is written

I am able to get an instance of the current ide

I will like to get a reference to dte2 of a different visual studio instance though. This link states that it is possible to do that. As a result I have tried something like:

    Process p = new Process();
    ProcessStartInfo ps = new ProcessStartInfo(@"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe");
    p.StartInfo = ps;
    p.Start(); // start a new instance of visual studio

    var ROT = "!VisualStudio.DTE.10.0:" + p.Id;

    // Get an instance of the NEW instance of Visual Studio IDE.
    EnvDTE80.DTE2 dte2;
    dte2 = (EnvDTE80.DTE2)System.Runtime.InteropServices.Marshal.
    GetActiveObject(ROT); 

If I try that I get the exception:

Invalid class string (Exception from HRESULT: 0x800401F3 (CO_E_CLASSSTRING))

There are more links that show how to do what am I looking for but for some reason I cannot make it work. Here are some of the links:

http://msdn.microsoft.com/en-us/library/6cefss65.aspx

http://msdn.microsoft.com/en-us/library/ms228755.aspx

  • 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-06-08T14:25:40+00:00Added an answer on June 8, 2026 at 2:25 pm

    One thing that has worked for me consistently is

    var dte = GetDTE();
    var debugger = dte.Debugger;
    var processes = debugger.LocalProcesses;
    int processIdToAttach; //your process id of second visual studio
    foreach (var p in processes)
    {
        EnvDTE90.Process3 process3 = (EnvDTE90.Process3)p;
        if (process3.ProcessID == processIdToAttach)
        {
            if (!process3.IsBeingDebugged)
            {
                if (doMixedModeDebugging)
                {
                    string[] arr = new string[] { "Managed", "Native" };
                    process3.Attach2(arr);
                }
                else
                {
                    process3.Attach();
                }
            }
            break;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking to get an instance of Solr search running on my localhost. The
We're currently running MySQL 5.0.36sp1, and I'd like to evaluate whether we would get
I am currently trying to get Tomcat up and running. It looks as though
I'm currently trying to get a simple bundle containing a Service Factory running. This
How do you get the SwingWorker that code is currently running in? You can
How do I get the web address of the currently running WCF service in
Why Microsoft.Practices.ServiceLocation.IServiceLocator does not offer TryGetInstance()? I need to get generic validator instance ServiceLocator.Current.GetInstance<IEntityValidator<TEntity>>()
I use the following to get, for instance, the header of the current page;
What I am trying to do is to get instance of Doctrine EM (using
I need to get an instance of the application's MembershipProvider from within a controller.

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.