0
votes

I need to measure the time I spend in break mode debugging my Projects. So I came up with the idea to write a custom VS extension which binds to the OnEnterBreakMode & OnEnterRunMode debugging events.

This works just fine, but I need to make sure my extension is loaded right at the startup of VS. Otherwise, the extension might not be loaded when I am already debugging.

Unfortunately Visual Studio 2019 heavily forces the user to use the AsyncPackage base class and set the BackgroundLoadingFlag. On default VS deactivates extensions which use the deprecated API, which allows synchronously loading extensions on startup.

Do you have any tips or workarounds on how I can make sure that my extension was loaded when I start debugging?

1

1 Answers

0
votes

So set your package to auto-load when the KnownUIContexts.DebuggingContext is activated, which means your package should be loaded once debugging has started -- there's no reason for you to load at startup if nobody every debugs anything in that session. Once your package loads, subscribe to those events, but also check the current state to see if you already entered break mode and missed the initial event. Rather than trying to "always load before the first event" it's often better to subscribe to events and just check the appropriate property to see if you are already in that state.

(And why do we not allow you to just load synchronously at startup? Because then everybody does that because it's easy, and your Visual Studio takes a real long time to load.)