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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:21:43+00:00 2026-05-16T23:21:43+00:00

I have a Visual Studio 2010 extension, a .vsix file. I can obtain the

  • 0

I have a Visual Studio 2010 extension, a .vsix file. I can obtain the DTE instance for my particular instance of Visual Studio, which I confirm by printing the dte_instance.Solution.Fullname. But for my DTE2 instance it appears to be giving me information about the wrong Visual Studio instance.

Here is the work flow: Visual Studio development IDE open, has code for the extension. Launch the project, which causes a new Visual Studio instance to launch which has the extension installed in it. Click my menu button (in the new IDE) that runs the following code:

DTE dte;
DTE2 dte2, dte2Macros;
dte = (DTE)GetService(typeof(DTE));
dte2 = (DTE2)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.10.0");
dte2Macros = (DTE2)dte2.MacrosIDE;

//this returns what I expect, the solution name in the newer IDE.
MessageBox.Show("solution name: " + dte.Solution.FullName);

//code to get the startup project from MSDN
//http://msdn.microsoft.com/en-us/library/ms228782.aspx
SolutionBuild2 sb = (SolutionBuild2)dte2.Solution.SolutionBuild;
string msg = "";
Int32 configs = sb.SolutionConfigurations.Count;
foreach (String item in (Array)sb.StartupProjects)
{
    msg += item;
}

//this returns a project from the development IDE, the one I don't want.
System.Windows.Forms.MessageBox.Show("startup project is: " + msg);
Project startupProject = dte2.Solution.Item(msg);

I found several references to acquiring the DTE2 object in an addin with the connect() method, but I could not locate a similar callback for extensions.

The question: how does one get the DTE2 instance for the IDE an extension is executing in?

  • 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-16T23:21:44+00:00Added an answer on May 16, 2026 at 11:21 pm

    Try this, which uses an imported service provider, or just use Package.GetGlobalService:

    DTE2 dte2 = Package.GetGlobalService(typeof(DTE)) as DTE2;

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

Sidebar

Related Questions

In my Visual Studio 2010 project I have files with .mm file extension, that
I've written a Visual Studio 2010 extension. It's a VS Package (in a .VSIX)
I have been developing a Visual Studio extension as an Add-in for VS2008/2010. The
I have visual studio 2008 installed on my PC. Can anyone tell me what
I have a number of custom Item and Project Templates for Visual Studio 2010.
I have Visual studio 2010 Premium installed on Windows 7. When I try to
I'm trying to write a Visual Studio 2010 Extension to show an IronPython shell
Recently I installed in Visual Studio 2010 the Power Tools Extension It's working great,
I have create a LINQ-to-SQL project in Visual Studio 2010 using Dynamic Data. In
does anyone know of a tool or extension to Visual Studio 2010 to count

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.