In the Package constructor I added the event handler for OnStartupComplete event. But when I run the code, the the event handler is not called. What am I doing wrong?
相关问题
- Respond to dialog boxes using DTE.ExecuteCommand
- How to handle pressing any keys in the user contro
- Visual Studio Extension: Get the path of the curre
- Programmatically adding and editing the Targets in
- How to notify the editor about document changes
相关文章
- How to get a programmable interface to the Visual
- How do I list all the projects in the current solu
- How do I programmatically add a file to a Solution
- Create Visual Studio Theme Specific Syntax Highlig
- How do you cancel a ToolWindowPane or Visual Studi
- How to deploy and register a VSPackage supporting
- Visual Studio SDK - Handle File Save Event
- Get full list of available commands for DTE.Execut
There's a bug in VS that recycles the
DTEEvents
object (with your event handlers) unless you keep an explicit reference to it. You need something like this:See my answer here: http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/eb1e8fd1-32ad-498c-98e9-25ee3da71004
I believe that it is because you could be boxing and unboxing your DTE object before doing the event subscription. This is a huge nuisance, and quite surprising that the DTE object cant be passed around easily through service location for the purpose of event subscriptions; but this seems to be the culprit.
I had tried to keep a reference to the DTE object but it made no difference as I was doing that anyway. Some events will work, and some won't; but this is consistent.
Try moving your code from package constructor to the Initialize() method of the package. It should help, but if it doesn't, test some other UICONTEXT_??? values for your AutoLoad attribute, maybe UICONTEXT_NoSolution ?