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

  • Home
  • SEARCH
  • 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 9122785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:11:04+00:00 2026-06-17T06:11:04+00:00

I used the Add-In for Visual Studio wizard to create a new Addin project

  • 0

I used the “Add-In for Visual Studio” wizard to create a new Addin project and now, I’m trying to add some event handlers:

public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
    _applicationObject = (DTE2)application;
    _addInInstance = (AddIn)addInInst;

    _applicationObject.Events.BuildEvents.OnBuildBegin += BuildEvents_OnBuildBegin;
    _applicationObject.Events.BuildEvents.OnBuildDone += BuildEvents_OnBuildDone;
    _applicationObject.Events.SelectionEvents.OnChange += SelectionEvents_OnChange;
    _applicationObject.Events.DocumentEvents.DocumentOpened += DocumentEvents_DocumentOpened;
    _applicationObject.Events.DocumentEvents.DocumentSaved += DocumentEvents_DocumentSaved;
}

But whatever I do, my handlers are never executed!

Am I blind? Do I have to do anything else to register these handlers or why doesn’t it work?

  • 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-17T06:11:05+00:00Added an answer on June 17, 2026 at 6:11 am

    Seems you’re a victim of the Garbage Collector. See: http://www.mztools.com/articles/2005/mz2005012.aspx

     private readonly BuildEvents _buildEvents;
     private readonly SelectionEvents _selectionEvents;
     private readonly DocumentEvents _documentEvents;
     private readonly Events _events;
    
     public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
     {
         _applicationObject = (DTE2)application;
         _addInInstance = (AddIn)addInInst;
         _events = _applicationObject.Events;
    
         _buildEvents = _events.BuildEvents;
         _buildEvents.OnBuildBegin += BuildEvents_OnBuildBegin;
         _buildEvents.OnBuildDone += BuildEvents_OnBuildDone;
    
         _selectionEvents = _events.SelectionEvents;
         _selectionEvents.OnChange += SelectionEvents_OnChange;
    
         _documentEvents = _events.DocumentEvents;
         _documentEvents.DocumentOpened += DocumentEvents_DocumentOpened;
         _documentEvents.DocumentSaved += DocumentEvents_DocumentSaved;
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used Visual Studio 2012 and the built-in template (under Add -> New Project)
I used Visual Studio 2012 and the built-in template (under Add -> New Project)
In Visual Studio when you add a new controller to your MVC application some
I have some libs that are used by my C++ Visual Studio project. But
I recently created a (C#) project with Visual Studio (2010) and used some Settings
In the past, using mercurial with Visual Studio, I used to add mercurial changeset
I've used Visual Studio's Add Service Reference feature to add a service (actually it
I used to have a nice little Visual Studio Add-In that allowed me to
I'm creating an Addin to be used in Outlook 2010 using Visual Studio 2008
I used the RC version of Visual Studio 2012 to create an ASP.NET Webforms

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.