views:

104

answers:

4

I'm working on an add-in for Visual Studio 2005 in C#, and while everything works if I launch it from the debugger, actually installing it (adding the .addin and .dll to the add-ins directory) results in it not working. When Visual Studio loads it, I get the error "The Add-in "MyAddin" failed to load or caused an exception." With Error Message: Unspecified error, with error number: 80004005, and then offers me the ability to disable it.

From here, I can't figure out how to debug that load process in order to figure out what's going on. I can't seem to attach to the dll before it's loaded, or specifically launch the dll in a fashion that causes it to load in the same fashion. I also can't attach when the error message is up.

How on earth do I do this?

Edit: I'm starting to believe this isn't a problem with my code so much as the .addin file. Given that I can't break the code in the constructor, and the MyAddin - For Testing.addin works, perhaps it is a larger issue with the generated MyAddin.addin file.

A: 

Add the line below at the beginning of your code. This will prompt you if you'd like to open up a VS window to debug (see MSDN). Then you can step through your code as needed.

Debugger.Break();

There is a benefit of using this method over "Attach to Process" in that you won't have to worry about attaching to the process each time and before the exception occurs.

Taylor Leese
Doesn't work. The error pops before anything breaks.
Charles Randall
Hmmm, well if you added this line at the beginning of your code then it would seem it's never even making it to the Debugger.Break() statement so you have some larger issues at hand.
Taylor Leese
A: 

The easiest way, which might not trigger the same exception:

  • Disable the load on startup.
  • Start 2 Visual Studio instances.
  • Use Tools -> Attach to Process to attach it as a debugger to the other instance.
  • Optionally also set Debug -> Exceptions to break on all CLR exceptions.
  • Load the addin in the debuggee
Sander Rijken
A: 

Maybe it requires a native side break point on appearances of 80004005 in devenv.exe. This usually requires you are familiar with WinDbg or so on.

If your company has a support contract with Microsoft, open a support case via http://support.microsoft.com to involve the experts.

Lex Li
A: 

After sleeping on it, I came back fresh and re-looked at everything. Turns out the generated .Addin file had a broken reference, and so was trying to load a non-existent file. After fixing the reference, everything works great (including 30 Break()s being called during visual studio start-up... but at least I know that was working.)

Charles Randall