Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / Extensibility / August 2005

Tip: Looking for answers? Try searching our database.

Event is only fired once

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gustavo Guerra - 17 Aug 2005 16:12 GMT
I have a CustomControl hosted on a Tool Window that hooks up one of it's
methods to the WindowEvents.WindowActivated event in the constructor. The
code is this:

_dte.Events.get_WindowEvents(null).WindowActivated +=  new
_dispWindowEvents_WindowActivatedEventHandler(windowActivated);

The problem is that my delegate is only called once, and then stops to
respond to the event. If I rehook the event at the end of the
windowActivated method, I gradually start getting the event multiple times.

Any solution for this?

Best Regards,
Gustavo Guerra
"Ed Dore [MSFT]" - 18 Aug 2005 01:06 GMT
Hi Gustavo,

You need to keep that WindowEvents object in scope, otherwise your event
handler gets eaten by the garbage collector.

Sincerely,
Ed Dore [MSFT]

This post is 'AS IS' with no warranties, and confers no rights.
Gustavo Guerra - 18 Aug 2005 02:28 GMT
Thanks. That is a very strange behaviour, though, as that WindowEvents
appears to be rooted at the VS instance.

Best regards,
Gustavo Guerra

> Hi Gustavo,
>
[quoted text clipped - 5 lines]
>
> This post is 'AS IS' with no warranties, and confers no rights.
Carlos J. Quintero [VB MVP] - 18 Aug 2005 10:10 GMT
Hi,

I have just written a MSDN Knowledge Base article about this (it can take
some minutes to appear live)

PRB: Visual Studio .NET events being disconnected from add-in.
http://support.microsoft.com/default.aspx?scid=kb;en-us;555430

Signature

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

> Thanks. That is a very strange behaviour, though, as that WindowEvents
> appears to be rooted at the VS instance.
>
> Best regards,
> Gustavo Guerra

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.