none
Add-In suddenly won't load RRS feed

  • Question

  • Hi, I'm a completely new to Visual Studio Extensibilty therefore I apologize for any stupid questions.

    My problem is as follows:

    I'm developing an add-in for Visual Studio using Visual Studio 2010.

    Recently, I've made some changes within the class connect.cs. I've refactored variable names.

    When I tried to debug the add-in, the UI didn't load in the experimental instance of VS.

    I tried to load it via the add-in manager but I got the error message that the add-in failed to load.

    I quit the debugging process an undid the refactored changes (so everything was back to when it worked before). And how could be any different (I wouldn't be writing this post otherwise) the add-in still won't load when I want to debug it.

    In a second try (that's the second try to debug after undoing the refactored changes) I also got the error message, that the *.dll could not be delete because the access was denied.

    So all of the sudden, everything broke. What have I done? And, more importantly, what can I do, to get it working again?

    Thank

    Chris

    Thursday, August 23, 2012 11:43 AM

Answers

  • Hi,

    See:

    HOWTO: Troubleshooting Visual Studio and Office add-ins
    http://www.mztools.com/articles/2007/MZ2007009.aspx


    MZ-Tools: Productivity add-ins for Visual Studio: http://www.mztools.com. My blog about developing add-ins: http://msmvps.com/blogs/carlosq/

    • Marked as answer by c.blume Monday, August 27, 2012 5:37 AM
    Thursday, August 23, 2012 1:54 PM
    Moderator
  • What I did now, was to setup a new project (in a new solution as well) and imported all the source files from the previous one (just in case I messed up some properties or references within an .AddIn file or somewhere else).

    First build succeeded as opposed to the previous solution, where the .dll could not be deleted since access to the path was denied (I've checked on the file system and the file was *not* read-only and I also turned off indexing and the "ready for archiving" flag.

    Trying to *debug* the add-in I got the following error message:

    The Add-in '<Add-in name>' failed to load or caused an exception.

    Would you like to remove this Add-in?

    If you choose yes, the file it was loaded from, 'C:\Documents and Settings\<user>\My Documents\Visual Studio 2010\Addins\<Add-in name> - For Testing.AddIn', will be renamed.

    Error Message: <Unknown Error> [sic!]

    Error number: 80131604

    I've checked the <Add-in name> - For Testing.AddIn file and the <Assembly> tag points to the correct assembly (c:\documents and settings\<user>\my documents\visual studio 2010\Projects\<project name>\<Add-in name>\bin\<add-in>.dll

    After that I've also checked Carlos' referenced article (http://www.mztools.com/articles/2007/MZ2007009.aspx) after that I put in some try/catch blocks into the code of the Connect.cs class, every where I added code to a method. Since then, I didn't get the error message from above anymore, so I guess that's progress (although I don't know why try/catch blocks changed that). Also, I've edited the <LoadBehavior> and <CommandPreload> tags in the <Add-in name> - For Testing.AddIn file (both to 1, the former value was 0 although I've checked to load the add-in on IDE startup in the add-in wizard).

    Anyway, although the build now succeeds and the experimental instance starts without an error message (also no exception gets caught since no stack traces a printed onto the console) everything works fine. Except...

    My UI is being displayed in the menu bar (big success!) but it's not active. It's disabled so I can't interact with it. Again, I've checked Carlos' article (btw. good job, helped a lot. Thanks!). 

    The Connect.cs class implements the IDTCommandTarget and the QueryStatus() method (well of course, since I've copied almost the entire code from the former project which at one point worked well - anyway, could there be the problem? Did Visual Studio, since I've just copied the code, miss to set some references or pull some triggers?).

    It seems that my add-in's command bar is enabled at first, but right when the experimental instance of VS has finished loading it gets disabled immediately.

    I would assume that the problem is somewhere in the AddPermanentUI() method, rather than the QueryStatus() method. That's because it's where I create the command bar for my add-in (with buttons and sub-menus). For clarification: I've used this article http://www.mztools.com/articles/2005/MZ2005003.aspx (thanks again, Carlos) as a template for my add-in (the C# parts for the permanent UI). There, as well as in the QueryStatus() method, is no reference to the command bar, where it would be set to "supported" and "enabled". That's clear, because it's no command after all, but a command bar.

    This is where I stand right now and I don't see why it won't work. All the more since it worked before hundreds of times.

    Hopefully one of you knows where the problem is (I'm sure it's so obvious and I don't see it). 

    Greetings

    Chris

    #### EDIT ####

    Okay, I might have narrowed it down to a class I've created.

    In the Connect.cs' constructor I create an instance of another class.

    Surrounded by a try/catch block I get the behavior described above (everything works fine except my menu is disabled. Without the try/catch block I get the error message saying that the Add-in failed to laod because of an exception (interesting: though I've put Console.WriteLine(e.StackTrace.ToString()) into the catch block, there is nothing being displayed.

    Anyway, I must've made some changes to said class yesterday that caused this trouble - or at least I hope so. I go through it and keep you updated.

    But if you think you've got another idea, I'll be happy to hear about it.

    Thanks

    Chris



    • Edited by c.blume Friday, August 24, 2012 8:52 AM
    • Marked as answer by c.blume Monday, August 27, 2012 5:37 AM
    Friday, August 24, 2012 8:06 AM

All replies

  • Hi,

    See:

    HOWTO: Troubleshooting Visual Studio and Office add-ins
    http://www.mztools.com/articles/2007/MZ2007009.aspx


    MZ-Tools: Productivity add-ins for Visual Studio: http://www.mztools.com. My blog about developing add-ins: http://msmvps.com/blogs/carlosq/

    • Marked as answer by c.blume Monday, August 27, 2012 5:37 AM
    Thursday, August 23, 2012 1:54 PM
    Moderator
  • What I did now, was to setup a new project (in a new solution as well) and imported all the source files from the previous one (just in case I messed up some properties or references within an .AddIn file or somewhere else).

    First build succeeded as opposed to the previous solution, where the .dll could not be deleted since access to the path was denied (I've checked on the file system and the file was *not* read-only and I also turned off indexing and the "ready for archiving" flag.

    Trying to *debug* the add-in I got the following error message:

    The Add-in '<Add-in name>' failed to load or caused an exception.

    Would you like to remove this Add-in?

    If you choose yes, the file it was loaded from, 'C:\Documents and Settings\<user>\My Documents\Visual Studio 2010\Addins\<Add-in name> - For Testing.AddIn', will be renamed.

    Error Message: <Unknown Error> [sic!]

    Error number: 80131604

    I've checked the <Add-in name> - For Testing.AddIn file and the <Assembly> tag points to the correct assembly (c:\documents and settings\<user>\my documents\visual studio 2010\Projects\<project name>\<Add-in name>\bin\<add-in>.dll

    After that I've also checked Carlos' referenced article (http://www.mztools.com/articles/2007/MZ2007009.aspx) after that I put in some try/catch blocks into the code of the Connect.cs class, every where I added code to a method. Since then, I didn't get the error message from above anymore, so I guess that's progress (although I don't know why try/catch blocks changed that). Also, I've edited the <LoadBehavior> and <CommandPreload> tags in the <Add-in name> - For Testing.AddIn file (both to 1, the former value was 0 although I've checked to load the add-in on IDE startup in the add-in wizard).

    Anyway, although the build now succeeds and the experimental instance starts without an error message (also no exception gets caught since no stack traces a printed onto the console) everything works fine. Except...

    My UI is being displayed in the menu bar (big success!) but it's not active. It's disabled so I can't interact with it. Again, I've checked Carlos' article (btw. good job, helped a lot. Thanks!). 

    The Connect.cs class implements the IDTCommandTarget and the QueryStatus() method (well of course, since I've copied almost the entire code from the former project which at one point worked well - anyway, could there be the problem? Did Visual Studio, since I've just copied the code, miss to set some references or pull some triggers?).

    It seems that my add-in's command bar is enabled at first, but right when the experimental instance of VS has finished loading it gets disabled immediately.

    I would assume that the problem is somewhere in the AddPermanentUI() method, rather than the QueryStatus() method. That's because it's where I create the command bar for my add-in (with buttons and sub-menus). For clarification: I've used this article http://www.mztools.com/articles/2005/MZ2005003.aspx (thanks again, Carlos) as a template for my add-in (the C# parts for the permanent UI). There, as well as in the QueryStatus() method, is no reference to the command bar, where it would be set to "supported" and "enabled". That's clear, because it's no command after all, but a command bar.

    This is where I stand right now and I don't see why it won't work. All the more since it worked before hundreds of times.

    Hopefully one of you knows where the problem is (I'm sure it's so obvious and I don't see it). 

    Greetings

    Chris

    #### EDIT ####

    Okay, I might have narrowed it down to a class I've created.

    In the Connect.cs' constructor I create an instance of another class.

    Surrounded by a try/catch block I get the behavior described above (everything works fine except my menu is disabled. Without the try/catch block I get the error message saying that the Add-in failed to laod because of an exception (interesting: though I've put Console.WriteLine(e.StackTrace.ToString()) into the catch block, there is nothing being displayed.

    Anyway, I must've made some changes to said class yesterday that caused this trouble - or at least I hope so. I go through it and keep you updated.

    But if you think you've got another idea, I'll be happy to hear about it.

    Thanks

    Chris



    • Edited by c.blume Friday, August 24, 2012 8:52 AM
    • Marked as answer by c.blume Monday, August 27, 2012 5:37 AM
    Friday, August 24, 2012 8:06 AM