I'm totally confused as to how to debug an Outlook 2010 addin I'm trying to develop. I created a new Extensibility | Shared Add-in project and just checked Outlook, and it's created a new project for me with a stub implementation of the Extensibility.IDTExtensibility2 interface in my Connect.cs file. However, when I press F5 to debug, although the project compiles OK, a new instance of Visual Studio opens up instead of Microsoft Outlook! How am I supposed to debug my addin?
Since Outlook is the host process that will load your code you have to make sure that Outlook is the target application for debugging (go to project properties and select the main Outlook EXE under the Start external program option in the Debug settings).
Then of course you have to also make sure that your plugin is actually being loaded by Outlook. With that in place you should be able to debug your plug-in with VS.
Related
I have built an add-in which works fine in Excel online, whereas it does not work in Excel 2016 for Windows.
I know that in Windows 10, we could use this tool to debug the add-in, however I am using Windows 7.
I just installed Visual Studio 2017, right clicking on the add-in shows a menu where Attach Debugger is. But clicking on Attach Debugger fires nothing.
Does anyone know how to debug in this case?
Two potential options:
You can use Volorn.js to remotely debug your add-in. You can use the Debug Office Add-ins on iPad and Mac article as a starting point. Although this article is targeting Mac and iPad, the concepts are the same for Windows.
You can also use Visual Studio by creating a new Excel Web Add-in. Simply replace the default manifest with your own. Note that you still need to retain the default web site, Visual Studio still this for some library references. It will use your manifest's URL for the source location however.
Office applications use Internet Explorer for the web browser, so all settings from IE should carry over. I have found that if you disable (uncheck) both the Disable script debugging (Internet Explorer) and Disable script debugging (Other) options, your debugger breakpoints will be hit (I tested this in Outlook 2016).
You will need add debugger; statements to the source code to add breakpoints. When these statements are hit, a dialog like this should appear:
Simply select 'Yes' and a new instance of visual studio should open, with the debugger attached to your script.
I have had some trouble with my Excel Addin and the Windows Installer. I tried following the steps as set out in the demo (shown on Pluralsight) on a test project and it works fine.
For my custom addin, I used VS2010 and the addin targets Excel 2007. There are more projects in my solution than only the Addin project and the setup project. After I have run the msi file that I created with the setup project, then if I have a message box in the ThisAddIn_Startup method of the ThisAddin.cs class, then it shows the messagebox, but it does not display the Ribbon tab that I created in the same project. I have tried to see whether any errors show up by creating the VSTO_SUPPRESSDISPLAYALERTS and VSTO_LOGALERTS variables, but I don't see any logfiles. After I build the projects and create the msi and setup.exe files, I clean the solution in Visual Studio, and try the installation from the external msi file, since I'm testing this on the development computer for now. Perhaps I should add, that if I run the setup.exe file, I don't even get the messagebox.
My addin is not disabled, and is ticked in the COM-Addins dialog. I have the registry set up for HKEY_CURRENT_USER.
Why do I see the messagebox, but not my tab on the Ribbon?
I found that there was an exception when the Ribbon loaded, and this is why it did not show. When I cleared that problem, the Ribbon loaded correctly. The exception was not picked up by the debugging though, it just silently malfunctioned.
I believe you are using Ribbon XML not the Ribbon designer.
If Ribbon XML then add the following code in to your ThisAddin.cs
protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
{
return new Ribbon1();
}
I have created a VSTO toolbar application add-in for Visio 2007 (.NET Framework 4 Client Profile) using VS 2010. I first tried to publish it with ClickOnce deployment but this did not load on test pc's. After checking the msdn documentation, I then created a setup project following the instructions at http://msdn.microsoft.com/en-us/library/ff937654.aspx and still had the same result. The MSI completed but the toolbar is neither on (start at loadup option) or listed in the available toolbars when right clicking on the toolbar area.
In comparing the registries of the test PC and my development PC, I found that the key for the addin on my dev PC was HKEY_CURRENT_USER\Software\Microsoft\Visio\Addins\addinName instead of HKEY_CURRENT_USER\Software\Microsoft\Office\Visio\Addins\addinName per the instructions. I changed this in the setup project but it still had no effect. Any ideas on what else is needed?
I am trying to find my way around the addin concept of VisualStudio 2010 but I keep on getting the same error when I compile the solution:
"unable to delete file '.\bin\VSA.dll'. Access to the path [...] is denied"
I suspected this would happen when the addin is loaded in the "dev instance" of Visual Studio while I try to compile the solution, but the addin seems to be correctly ticked out in the "Add-In Manager" and the .Addin file contains <LoadBehavior>0</LoadBehavior> which should be right.
Any idea what could be causing the lock or how to track down what is? Thanks!
You have to restart VS for the addin to get unloaded, ticking out the checkbox won't unload the assembly from devenv.exe.
What seems to be working for me is to have the addin ticked out and start 2 instances of VS one with the adding project opened and one to debug the addin in.
Then enable the addin in the second instance to trigger the addin's initialization and debug it.
Disable the addin in the second instance of VS, close the VS.
Recompile the addin project in the first instance, start a second instance again.
Another simple way is to tick off the checkbox, close Visual Studio, delete the output files and finally restart Visual Studio.
Unlocker is a useful program for when you're unable to build because your dlls are locked.
Can someone give me a quick explanation of when I would use Visual Studio 2008 Outlook 2007 Ad-In project type? and how would that compare to developing a bunch of outlook macros directly in outlook?
Basically, I want to have some sort of application read email (with attachments) from a pop3 email box, do some filtering/editing/validation of the subject/sender/content and then if certain conditions are met, save the attachments to a local file, and then add an entry into an SQL server database table (i.e. date/sender/subject/message).
Seems there are at least 10 different ways to do this....so between an outlook macro and a VS Office Project, how do I pick?
I am not clear, if I create this solution as a Visual Studio outlook add-in, where does it run? Is it loaded into outlook, does it run as a separate process and communicates back and forth with outlook? if outlook is not running, does it start it?
An Outlook Add-on is a compiled component that uses the Outlook API to perform the tasks you need. A macro/VB script is an interpreted script that actually uses the same API. The add-on approach is better if you want to deploy your functionality.
When you work on an Outlook add-on in Visual Studio, you'll be creating a .NET component, which integrates into the Outlook application, which is written in C++ so uses COM. You'll have to be careful about managed/unmanaged types and releasing objects you retrieve from Outlook.
I have recently completed just such a tool, but I chose to use Add-in Express (http://www.add-in-express.com/). These guys provide a layer of abstraction over the [challenging] Outlook API and also provide some excellent support if you're stuck.
In my case, with Add-in Express, I "run" by setting Outlook as the application command to run, in the Project properties. Add-in Express sorts out the installation of the add-on within Outlook. So when I press "Run", Outlook starts and my add-in is displayed, which may be debugged in the normal fashion. I'm not sure how VSTO (Visual Studio Tools for Office) works in this respect - or at least, I can't remember.
This is an example of an outlook add-in..
Personally, I don't see macros distributable.