VSTO 2012: backward compatibility - c#

Since lately the Visual Studio Tools For Office 2012 (VSTO 2012) are available for download.
Can this new version still used for developing Add-In solutions for older Office versions (2007,2010)? Are there any advantages over VSTO 4.0 (besides Office 2013 support)

Yes, it can. I'm using VS2012 for an Excel 2007 project and it works fine.
The trick is to change the debug path in your project file so that VS uses the older version of the Office app your plugin is for.
Create your VSTO project (let VS create the project for Office 2010)
Edit the project file and find the <ProjectProperties> with a HostName attribute. It will be a child element of a <VisualStudio> element.
Change the DebuginfoExeName attribute value of the <ProjectProperties> attribute to be the path to the older version of the Office application .exe file
Save your project
Now when you go to debug your app it should launch the older version of your Office app and attach to that process to load your VSTO.
In my project, the new <ProjectProperties> element looks like this for Excel 2007:
<ProjectProperties
HostName="Excel"
HostPackage="{20A848B8-E01F-4801-962E-25DB0FF57389}" OfficeVersion="14.0"
VstxVersion="4.0"
ApplicationType="Excel"
Language="cs"
TemplatesPath=""
DebugInfoExeName="#Software\Microsoft\Office\12.0\Excel\InstallRoot\Path#excel.exe"
AddItemTemplatesGuid="{51063C3A-E220-4D12-8922-BDA915ACD783}" />
Deployment also works fine. I deploy my add-in via ClickOnce and it is added to Excel 2007 clients without any additional changes.

As far i know you can deploy your solution to previous version office. I once developed an add-in for ppt 2013 and it worked fine in ppt 2010. Note that The API for the new VSTO has several additional features and last time i only used existing features, but not the new ones.
I've never tested this, but i think if you use new event handler that only works in 2013, when you deploy it in 2010 it simply does nothing / doesn't work.
As i mentioned, the obvious advantage of new VSTO is more features available, for example in ppt 2013, it has event handler when the users do dragging, you should checked them by yourselves. If your solution doesn't need these new features, you can develop it in the previous version of VSTO to make sure the backward compatibility.

Related

Excel Addin For Excel 2010 & Excel 2013 in Visual Studio

I have a Excel addin written in VBA which iterates through used range of a sheet and manipulates cell values. Its a simple addin but now user requirements have changed and I want to develop it in C# in Visual studio. For this purpose i was looking into VSTO but as far as i can understand in visual studio you can develop addin for a single version of excel. I have to give support for excel 2010 and excel 2013. What should I do to overcome this issue. which visual studio version i should use?
Any version of Visual Studio from 2010 to the present should be able to create VSTO Add-ins for Excel 2010. From VS 2012 onwards, also for Office 2013. Which set of templates you see in the later versions depends on 1) the version of Office installed and 2) the version of the .NET Framework selected when creating the project (4.0 for 2010; 4.5 for later). More information can be found on this page: https://blogs.msdn.microsoft.com/vsto/2013/03/06/office-developer-tools-for-visual-studio-2012-now-available-with-office-2013-and-net-framework-4-5-support/
Note that you should have only one version of Office installed in the development environment.
If possible, you should develop the Add-in for Excel 2010. An Add-in developed for an older version will run for a newer version, without you needing to do anything in addition - assuming Microsoft hasn't made changes to the parts of the object model you use which will "break" it. Since Microsoft pays special attention to backwards compatibility, this is usually not a problem, but thorough testing is important. It is not necessary to re-build or otherwise change the installation for installing to a newer version of Office.
One important reason to develop against the older version is that forwards compatibility is not supported. In other words, if you should use something in the newer version that's not present in the older one, that code will fail.
Also, the VSTO functionality will automatically "re-map" references made to an older set of PIAs to the newer ones for a newer version of Office. The reverse is not the case.
If for some reason it's not possible to program using the older version, as long as you have the .NET Framework 4.0 (or later) you can use the "Embed Interop types" property of a Reference to embed the PIA information in your project, so that it travels with your solution instead of referencing the PIAs installed in the GAC and makes them version independent. This is fine, in theory, but requires very thorough and careful testing since - besides the forwards compatibility problem - the actual information embedded does not always behave correctly.
you need to install visual studio 2013 for VSTO version 13 that support Excel 2013, but you can support excel 2010 by creating the installer file from the application. and there is no other way to support two different version from the code base at the same time
Thanks

Excel Addin does not compile properly on different machines

I have a very old Visual Studio Excel AddIn project.
When I compile it on my machine on VS2013 (.Net 4.0) and Office 2010 it works perfectly on the other machines. But when I compile it on TFS machine (no Office, only the vsto_redist.exe) it does not work - it does not load.
I've tried to switch on the VSTO_LOGALERTS and VSTO_SUPPRESSDISPLAYALERTS but this did not show any errors.
I've also tried to add a Microsoft.Office.Interop.Excel.dll to the project it still does not worked.
Any help on how I can see the problem will be helpful.
You need to install at lest the Excel developer tools that cinder in the box with office.

Upgrade Outlook 2003/07/10/13 addin to be used for Click-to-Run (C2R)

I have an addin that is compatible with Outlook 2003 - 2013 by using the various versions of VSTO.
It seems that the majority of small businesses will have the Click To Release version, which is not compatible with addins.
Is there a way to make an addin compatible with 2013 C2R, or does it need to be rewritten to be an "App" using Napa?
C2R Office installation load COM addins in exactly the same way as the regular version of the Office, there is nothing you need to do.
What is the exact problem that you are running into?

C# VSTO Project change from Excel 2010 to Excel 2007

I have a solution in VS2010 that was developed as an Excel 2007 add-in. Unfortunately something happened with my profile and since then VS runs the solution with Excel 2010. Somehow my profile got corrupted and my VS solution got corrupted too changing the Office library from 2007 to 2010. I tried changing the library back to 2007 but every time I open the VS solution VS changes it. Anyone has an idea how to fix this problem?
You must have installed Office 2010 which forces VS.NET to use the Office 14 PIAs. You can still deploy your add-in to Office 2007, you just have to be sure you don't use any Office 2010 specific features.
Also see related SO post .

C# dual Outlook 2007/2010 VSTO Add-in

We need to create a VSTO add-in in C# that supports both Outlook 2007 and 2010.
To start off we created 3 projects:
File->New Project->Office->2007->Outlook 2007 Add-in
File->New Project->Office->2010->Outlook 2010 Add-in
File->New Project->Windows->Class library
All shared code is in project #3.
So far, we have partially developed the add-in and have been using ClickOnce deployments for testing.
One day, we noticed someone installed the 2010 add-in for 2007 Outlook and had no ill effects whatsoever.
So a few questions:
Is there any reason to create the
2007 VSTO project? Can we just
create the 2010 project?
Or is the only difference the version of
the office runtime that is
bootstrapped by the ClickOnce
installer? Can you just install the 2010 runtime for Outlook 2007?
If there is no difference, why are
there two Visual Studio project
templates?
In our final solution, we will be using a WiX installer, which is also working thus far. The WiX installer will be simplified greatly if we can use 1 project for the add-in.
Is there any reason to create the 2007 VSTO project? Can we just create the 2010 project?
You can just use the 2010 project, but if you accidentally reference any 2010 ONLY api's, for example accessing any of the new conversation API's will cause your add-in to blow up in 2007.
Or is the only difference the version of the office runtime that is bootstrapped by the ClickOnce installer? Can you just install the 2010 runtime for Outlook 2007?
Basically you are writing a VSTO 3.0 add-in, which works for both 2007 and 2010. VSTO doesn't actually care which template you are writing for, only that your add-in is a VSTO 3.0 add-in.
If there is no difference, why are there two Visual Studio project templates?
2 reasons that I can see, F5 debugging support, and to make sure you do not access a new API'
If you do go down the only 2010 add-in road, I suggest you do a compile of the solution against the Microsoft.Office.Interop.Outlook v12 PIA which will show you any new API's that you are accessing. If you do want to target some of these new API's only IF your add-in is hosted in 2010 then have a look at http://blogs.msdn.com/b/vsto/archive/2010/06/04/creating-an-add-in-for-office-2007-and-office-2010-that-quot-lights-up-quot-on-office-2010-mclean-schofield.aspx

Categories

Resources