开发者

Side-effect on VS addin already installed, when installing/deinstalling an extra VS package

I noticed that at installation time of a VS package product (like http://www.continuoustests.com/ ) devenv.exe is started and I notice that sometime my VS addin is loaded (its OnConnection() method is called), and this could provoke a crash.

The problem is about sometime, since I cannot repro the conditions where my VS addin gets loaded. From my crash log, I know it happens rarely, only with VS2010 devenv.exe, and I know as well it is independent from the machine architecture x86 / x64. I tried installing/deinstalling extra addins having no VS instance running, or having VS instances running, VS2008 or VS2010.

Does anyone have a clue about how to reproduce the problem when my VS addin gets loaded?

Btw, I am pretty sure to have a fix for the problem, since in OnConnection() I already have code like that...

     switch (connectMode) {
        case ext_ConnectMode.ext_cm_External:   // This setting is no longer used by Visual Studio.   (http://msdn.microsoft.co开发者_JAVA百科m/en-us/library/extensibility.ext_connectmode%28v=vs.80%29.aspx)
        case ext_ConnectMode.ext_cm_CommandLine:// The add-in was loaded from the command line, don't support it so far
        case ext_ConnectMode.ext_cm_UISetup:    // addin loaded for the first time, we don't need it  (http://msmvps.com/blogs/carlosq/archive/2008/10/13/the-onconnection-method-and-ext-connectmode-ext-cm-uisetup-of-visual-studio-add-ins.aspx)
           return;

        case ext_ConnectMode.ext_cm_AfterStartup:
        case ext_ConnectMode.ext_cm_Startup:
        case ext_ConnectMode.ext_cm_Solution:
           break;
     }

... but once OnStartupComplete() is called back, I forgot to check the connectMode value I got in OnConnection(), hence the crash. Anyway being able to reproduce the bug would comfort me in the fix.


Update: 10 October 2011

After more testing and feedback from users that repro the problem, it appears that my theory was wrong: connectMode is actually in the range [ext_cm_AfterStartup, ext_cm_Startup, ext_cm_Solution].

The problem only occurs with VS2010 and comes from the fact the addin has no UI element, provoking something like dte.MainWindow, or HwndSource.FromHwnd(new IntPtr(mainWindow.HWnd)).RootVisual to be null.

I talked with Carlos Quintero http://msmvps.com/blogs/carlosq/, the world expert in VS addin, that has never observed this case. VS2010 shouldn't load any addin in the VS extension install/uninstall scenario, and it seems to occur randomly, or more likely, under unknown and rare conditions.

I'll put yet another try/catch to circumvent yet another VS2010 addin bug :(

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜