How do you create a ClickOnce MS Office Outlook add-in? - c#

The Outlook add-ins I have created using Visual Studio 2005 don't use the ClickOnce installer, just the regular Windows Installer.
(File -> New Project -> Extensibility -> Shared Add-In)
I need to create the add-ins using the ClickOnce installer because as far as I know that's the only way there is to sign the add-ins so they can run in spite of Macro Security settings on the clients' computers.
Can someone tell me how to create an Outlook add-in installer using ClickOnce?

Add an installer project to your solution. That will install the application to your program files directory which is trusted by default. It will require the end user to have admin privileged to install, but it does not require the installer files to be signed. It is not technically a click-once install, but it works very well for office add-ins.
Edit: You also need to add a reference to the addin to the registry. Check out Deploying a Visual Studio 2010 Tools for Office Solution Using
Windows Installer on MSDN. Figure 6 and the instructions preceding it describe how this is done.
The actual values to add to the registry key can be a bit confusing, so here are the ones that I used which work fine:
Description: "Provides functionality to access data from ..."
FriendlyName: "CompanyTools"
LoadBehavior: 3 (indicates that the add-in should be loaded at startup of the host application)
Manifest: "file:///[ProgramFilesFolder][Manufacturer]/[ProductName]/T360.Office.CompanyTools.vsto|vstolocal"
Also, I think that you need to add Microsoft.VisualStudio.Tools.Applications.Runtime.dll as a dependency. I don't think that it is by default.

Go to the project properties/Signing tab. Check "Sign the ClickOnce manifests" and provide your signing certificate.
Now go to the Publish tab. You need to fill in the publishing file location, which should be a URL or a file share. If the installation location is the same as the publish location, you can leave it blank.
Click the Prerequisites button and make sure the necessary prerequisites are selected.
Click the Updates button and pick how frequently to check or updates.
Click Options. Fill in the publisher name (typically your company), product name (how you want it to look in the uninstall page, and in the Add-Ins list in the Office product), and a support URL if you want. Check the Office Settings, too.
Fill in a publish version.
Click Publish Now. It will publish your deployment to the publishing file location.
You should be able to use the installation URL or publishing location to install the add-in. Note that if you have the Office product running, you need to close it and re-open it to load the add-in.

Related

Deploying Outlook Plugin C#

I developed an outlook plugin using C# and Visual studio Outlook addin template, that retrieves data from databases and generates a report off of the data.
Plugin works perfectly fine on my local machine. But when I distribute the plugin as an executable to the users, it does not work on the user's machine.
Meaning the addin is not checked by default and even if I check it manually, it does not show up on outlook in the addin bar.
I am unable to figure out if its due to the certificates or anything else.Do I need to install any certificates on the users machine ?
Could some one please help me out ?
EDIT
I right click on the solution file in solution explorer and publish to a folder to generate the setup.exe . My other team mate uses the same steps with the same project checked out of perforce and publishes a setup.exe. Now, his plugin works as expected on the user's machine and mine doesnot work (mine works only on my machine). So, I am not able to figure out what the difference is. Because we both are using the same framework (4.0) and VS (VS 2010 premium).It has something to do with the my machine. not sure if I am missing any installation
Did you have a chance to check out the Trust Center settings on the problematic PC? Are the VBA macro settings applied to COM add-ins? Is the Office application configured to load only signed add-ins?
Microsoft Office applications can disable add-ins that behave unexpectedly. If an application does not load your add-in, the application might have hard disabled or soft disabled your add-in.
Hard disabling can occur when an add-in causes the application to close unexpectedly. It might also occur on your development computer if you stop the debugger while the Startup event handler in your add-in is executing.
Soft disabling can occur when an add-in produces an error that does not cause the application to unexpectedly close. For example, an application might soft disable an add-in if it throws an unhandled exception while the Startup event handler is executing.
When you re-enable a soft-disabled add-in, the application immediately attempts to load the add-in. If the problem that initially caused the application to soft disable the add-in has not been fixed, the application will soft disable the add-in again.
Read more about that in the How to: Re-enable an Add-in That Has Been Disabled article.
Also you may find the Troubleshooting COM Add-In load failures article helpful.
Hope the following steps will help you solve this problem. I assume you are using Outlook 2013 or 2010.
Run the deployed setup with administration rights.
If it is not shown under Add-ins, again open the setup folder and double click on the correct .vsto file then select install.
If you can see your add-in among others, and is not functioning, it means your add-in is disabled. To enable it go to File -> Slow and Disabled Add-ins, and you should see your add-in on the pop-upped window. Enable it.
Edit:
If your plug-in is shown in Disabled Add-ins try applying the following steps:
Enable your plug-in by File -> Slow and Disabled Add-ins, and you should see your add-in on the pop-upped window. Enable it.
Right click on your add-in bar and select Customize the Ribbon.
Then on the pop-upped window, choose All Commands from the left hand side combo box. You should be able to find your command in the list box.
When you find your command click on the Add button between the lists. This will add your command to the chosen category on the right hand-side list. Then click OK.
Your command should appear under the chosen tab.
How are you deploying the add-in? You need to be sure you have configured the installations settings so when you execute the installer MS Outlook knows were to find it and all of its installations components.
In my example I am using MS Project, Visual Studio 2012 with Install Shield.
Below is an example of the registry settings I use for my add-in. You will notice I have configured the manifest to point to installation directory and points to vstolocal.
You will also need to add your .vsto file to your build when constructing the installer.

Deployment issues regarding some resources

I am having a issue regarding my deployment of my software in Visual Studio 2012. First of all I am not able to install the "InstallShield Limited Edition" through VS12 so I am currently testing out Advanced Installer instead.
Mys issue comes due to the fact that in my program I am fetching a .pdf file and modifying it and later on showing them to the user. These PDF:s is in the programs resources folder but does not follow with the installer, so my application crashes since it cannot find this. The same is for my .chm file (help file)?
My customer is using XP and when I try to publish the software directly from VS12 it works on my computer, Windows 8, but not on his computer. The application won't even start for him.
So how can I deploy my pdfs to the installer file, or why is this not accomplished already?
It seems that the PDF and CHM files are not imported automatically in the project. What type of project have you created in VS?
To add those files in the setup use the "Edit in Advanced Installer" button from the Advanced Installer VS extension and go to Files and Folders page. There you should add the two files in the desired folder and save the project.

Process of ClickOnce and prerequisites

I have an application I want to build and deploy via ClickOnce. But we want this to be a process that can be run outside of VS through scripts, for either test, business UAT or production environment.
Each separate environment requires a different .config file to be used and a different web server to be deployed on and for update location.
The application also has prerequisites of .NET runtime 3.5 and Crystal reports.
I have looked into using MAGE to create application and deployment manifests, and if I do a code BUILD, then use MAGE afterwards as per each environment, as well as having the script copy over the correct .config file, this creates what I think are the correct manifests for each environment at the time of running the script.
But what I'm struggling to do is include the prerequisites. If done through VS, you can specify a setup.exe package which gets built with the pre-reqs and deployed alongside the application and when you click on the download link, it installs the pre-reqs from setup.exe and then the application.
But how can I do this manually outside VS? I can build the setup.exe through VS with the right URl location but then how do I link the setup.exe to the application as a pre-req using MAGE to generate the manifests?
The problems we have are 1) The users do not have admin rights to download and install packages, only to install things via clickonce so the pre-reqs have to be installed under the click once security umbrella.
Thanks
ClickOnce and prereqs cause lots of confusion. The setup.exe that Visual Studio generates has nothing to do with ClickOnce. The only minor link between the two is that the setup.exe will launch the ClickOnce application once it finishes. That's it. So thinking users will be able to install your prereqs "under the clickonce security umbrella" is a mistake. If they are not an admin and a prereq install requires admin privileges, they won't be able to install it.
My advice would be to generate your setup.exe one time. You shouldn't need to keep doing it unless your prereqs keep changing. Use Visual Studio, generate the setup one time, then use Mage for the rest.
Edit
In general you make the setup.exe available and depend on the user to know if they need to run it or not. If they already have the prereqs and run the setup.exe, nothing bad happens. It sees that everything is installed then launches the app.
Usually you're going to direct users to run the setup.exe. The next time they want to launch the app they should use the start menu shortcut (assuming you didn't go with "Online Only"). I've found this to be the least confusing set of instructions for users.
Remember how Visual Studio does extra, non-ClickOnce stuff when you publish (like the setup.exe)? It also creates a simple html page that has links to both the ClickOnce manifest and the setup.exe and an explanation. It also has some javascript that checks the UserAgent string to determine if they have the .NET Framework installed. Again, this isn't ClickOnce. It's just something nice Visual Studio does for you. If you like it, use it. I kind of like skipping it and going with the run setup.exe to install then launch from the start menu.
codeConcussion is right, you can't ever actually have the prerequisites instill directly from ClickOnce. You should just generate it once and then you have it ready for your external ClickOnce tool.
There is an option other than Mage. You could use my companies tool, ClickOnceMore, as your ClickOnce build software. It's been designed for people who want to use ClickOnce but don't want to build with Visual Studio.
It can hook into the setup.exe generated from Visual Studio (details here) so should satisfy all your needs.
Why do you want to build setup manually if everything can be done via clickonce ?
You can select "Download pre-requisites from same location" option from prerequisites form if you want to include .netfx or crystalreports, download bootstrap packages for .netfx3.5 & crystalreports and add to folder (for windows 7) "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages" . The deployment project will automatically include netfx & other packages along with setup.exe.
hope this helps.

A second Excel Addin (Ribbon) installation appears when I open Excel, why?

I have made an Excel Add in (Ribbon).
When i run the .vsto and install it, i've one installation under Programs in Windows.
But, when I open my Excel program, another installation appears in the Programs-list.
Why is that and it shouldn't be like that right?
Update:
I notice in Application I have set Target framework: ".NET Framework 4 Client Profile"
and in Publish - Prerequisites it adds a Microsoft .NET Framework 4 Client Profile(x86 and x64), has that anything to do with it?
This can happen when you install the VSTO on your development computer. This is because when debugging the VSTO it will get installed though it won't show in the Programs & Features list. The VSTO will remain installed even after debugging is stopped. Even when performing a proper installation, remnants of the debugged VSTO will remain in the registry.
I've found the best way to work around this (though not ideal) is to manually remove the registry key at this location before performing a proper installation:
HKEY_CURRENT_USER\Software\Microsoft\Office\Word\Addins\[YOUR VSTO PROJECT NAME]
Because maybe in configuration you have set the application to update itself automatically.
So after Excel startup, it tryes to auto-update.
Is it possible?
It is very common to find two instances of the same add-in on your Excel application in a development machine. Since you must be building that add-in code inside your IDE before publishing or making a setup project build.
Whenever Excel starts it automatically detects the add-in manifests that are present on your computer.
Since you also installed your add-in your machine now has two locations where it finds your add-in one in your project folder and another at the location where you have installed the add-in.
So excel will, on its own add two add-ins because it found two add-ins, as simple as that.
And it has nothing to do with your Publish pre-requisites and Target framework.
You can simply go to FIlE->Options->Add-Ins-> over here in the window you'll find a Drop down with the label saying "Manage", in that select COM Add-ins and click on 'GO'.
Now in the window that opens, you'll find both your plug-ins listed there, you can remove the plugin that you do not want to see on your Excel app.
But, anyways the next time you build your excel add-in and start Excel it will again add that add-in automatically to your Excel app.
So it would be better not to install the add-in which you make on your machine until you want to test the installer or something like that.

My program has been "published", how can I change the installation path?

I "published" my C# solution in Visual Studio 2008 to C:\Deploy. When I run the setup.exe program, it installs my program to C:\Documents and Settings\Kevin\Start Menu\Programs\MyProgram
Is there any way, within Visual Studio, to set a custom install path? For instance, what if I wanted my program to install to C:\Program Files\MyProgram?
Publishing uses ClickOnce for deployment. ClickOnce has the advantage that it's easy to install and update, and doesn't require the user to have administrator privileges to install your application.
If you'd like a more traditional next-next-next-next-finish installer, which also allows the user to specify the target folder (and for you to set/force a default one), add a "Setup Project" to your solution by clicking File >> Add >> New Project..., in the tree select Other Project Types >> Setup and Deployment and double click Setup Project. When you build the setup project, it create an MSI file (Microsoft Installer setup file) and a bootstrapper EXE file (in case the user doesn't have Microsoft Installer or the required .NET Framework, which it then installs automatically).
ClickOnce ("published") applications are installed per user in the user application cache location. There is no way you can change this location ;-)
You have to use your own setup packaging tool in order to choose or let the user choose the location. Or you can just distribute your application as a zipped executable, if no installation routine has to be called, liked registering file types or adding keys to the registry.

Categories

Resources