Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't debug Visual Studio addin

Question says it all. I'm trying to write a Visual Studio addin (2012), and the experimental instance always launches without running anything in the addin. No breakpoints are hit in the main instance, nor does the addin get loaded by the experimental instance.

I should point out: it worked at one point once or twice, then I deleted the project since I thought it was the wrong kind of project, but ended up recreating it with the same name.

No amount of fiddling with "allowing addins to load" or resetting the experimental instance or cleaning the registry manually fixes the problem. I also tried looking for my addin dll, but it wasn't in the list. I'm totally out of ideas and possible search terms. Any suggestions?

like image 555
gzak Avatar asked Jan 26 '13 20:01

gzak


People also ask

How do I Debug a Visual Studio add-in?

Start the Excel, PowerPoint, or Word add-in projectStart the project by choosing Debug > Start Debugging from the menu bar or press the F5 button. Visual Studio will automatically build the solution and start the Office host application.

How do I enable debugging code in Visual Studio?

To bring up the Run and Debug view, select the Run and Debug icon in the Activity Bar on the side of VS Code. You can also use the keyboard shortcut Ctrl+Shift+D. The Run and Debug view displays all information related to running and debugging and has a top bar with debugging commands and configuration settings.

How do I Debug an add-in?

When your add-in loads in the Office host application, open the task pane. Return to Visual Studio Code and choose View > Debug or enter CTRL + SHIFT + D to switch to debug view. From the Debug options, choose Attach to Office Add-ins. Select F5 or choose Debug -> Start Debugging from the menu to begin debugging.

How do I fix the Debug executable in Visual Studio?

Just use File/Open Project/Solution, select EXE file and Open it. Then select Debug/Start debugging. The other option is to run the EXE first and then Select Debug/Attach to process.


2 Answers

I had the same problem as you and have just discovered the fix for me, it relates to the new "file properties" entry in the add-in project that gets supplied.

If you open this file which is in my case called "[App Name] - For Testing.AddIn" you'll see XML markup containing things like the AddIn friendly name, description e.t.c.

For me I found that I'd immediately renamed the output assembly for my project and this no longer matched that found inside this properties file:

<Extensibility xmlns="http://schemas.microsoft.com/AutomationExtensibility">
<HostApplication>
    <Name>Microsoft Visual Studio</Name>
    <Version>11.0</Version>
</HostApplication>
<Addin>
    <FriendlyName>My Addin</FriendlyName>
    <Description>My Addin description.</Description>
    **<Assembly>E:\Workspaces\Scratch\MyApp\bin\MyApp.VisualStudio.Addin.dll</Assembly>
    <FullClassName>MyApp.VisualStudio.Addin.Connect</FullClassName>**
    <LoadBehavior>1</LoadBehavior>
    <CommandPreload>1</CommandPreload>
    <CommandLineSafe>0</CommandLineSafe>
</Addin>

I checked the name of the assembly and class names fixed them up, saved the file and hit debug and it all started working again! Hope this helps...

like image 118
The Senator Avatar answered Nov 15 '22 10:11

The Senator


I had a similar problem... fought with it for quite a while, and eventually, absolutely randomly experimented with adding other configurations to the project (Configuration Manager) and also changing the framework.

One of the two magically helped. (I think it may have been the framework... though it makes no sense).

I am not saying that the same thing will work for you.

The random experiment was not really random: I got hold of a "debuggable" add-in off the web, and compared every single item in the project, solution and all other files, to find what could be different. This is my true suggestion.

If all else fails, you can also try to manually attach the debugger, see if you can make headway this way. [ that did not work for me, but it may provide valuable information, and... not all bugs are created the same. ]

like image 34
Thalia Avatar answered Nov 15 '22 09:11

Thalia