I wrote a .NET add-in that reference office interop assemblies with version 12 (office 2007). When I load the add-in on machines with interops with version 14, office loads this version successfully (it redirects to office 14).
BUT (and here comes the problem), on some machines it still requires version 12 although version 14 exists. Placing version 12 fixes the problem on these machines, but why does it happen???
Make sure that you don't use methds and properties introduced in later Office versions (2010 and later). Thus, you will be sure that your add-in will not fire exceptions at runtime.
The Running Solutions in Different Versions of Microsoft Office page states the following:
Solutions that were created by using Visual Studio 2013, Visual Studio 2012 or Visual Studio 2010 can run in Office 2013, Office 2010, or the 2007 Microsoft Office system. However, the solution can use only those features and APIs that are available in all three versions of Office.
BUT (and here comes the problem), on some machines it still requires version 12 although version 14 exists. Placing version 12 fixes the problem on these machines, but why does it happen???
The add-in shouldn't depend on the PIAs installed. You just need to include the required PIAs into the installer and use APIs available in the lowest Office version. That's all.
Related
I'm coding one of my first projects in Visual Studio 2017 using the Microsoft Office Interop Tools to basically open some Word files, extract some content and export it to an XML file.
I know that on the target machine Office should be installed and actually on that PC a 2010 installation is licensed, while on my PC I have a 365 suite.
The first build was working only on my PC, with missing references errors to the interop library on the production PC, so I've downloaded the Microsoft Office 2010: Primary Interop Assemblies Redistributable
https://www.microsoft.com/en-us/download/details.aspx?id=3508 to include as a reference in my project, replacing the 2016 one.
First difficulty was: Once installed I cannot find the files on my drive, nor a reference inside visual studio, nor in the documentation. Is there any info about where to pick the dll?
So I unzipped from the cab the WORDPIA.DLL on an handy directory and referenced it in my project.
While is it working locally, it isn't yet on the production PC.
I'm sure I'm missing a lot of points on this topic, VS & C# are not my territory, but I need some tips to finish the project.
Go back to the original project (or reference the version of the PIAs installed on your machine). The redistributable is intended for installing to an Office 2010 machine where the PIAs were not installed. It's not meant to be used in the manner you envision.
Now click each "interop" reference entry and look at the Properties window. There should be a setting for "Embed Interop Types". Set that to True. This should make the project version-independent as it will contain the PIA information your project uses.
Note that "embed interop types" was introduced with .NET Framework 4.0 and is not available for earlier versions of the Framework. If an earlier version is a requirement, then you have to use late-binding or develop your project using Office 2010.
I want to create a Add-In. I will create in VS 2013. I just don't know what is minimum version support of Ms Office.
Can anybody please suggest me? So, I can take case of the requirement.
VS2013 will natively support 2010 and 2013, but it is possible to support 2007 as well.
Per Microsoft's article on running solutions in different version's of Office:
If you developed solutions for Office 2010, you can run the same solutions in Microsoft Office 2013. If your customer base uses the 2007 Microsoft Office system, you can use Visual Studio 2013 to develop solutions that work in all three versions of Office. In this scenario, the solution will run without errors in the 2007 Microsoft Office system only if the solution doesn’t use features that are new in later versions of Office. Microsoft Office applications can also run solutions that were created by using a previous version of 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
I have created an add In using VS2013 with targeted framework 4.5. Its working fine in Outlook 2013 (System spec: Windows 8.1, Visual studio 2013 and office 2013).
But when I try to use the same in Outlook 2010 I am getting an error message "The common language runtime could not be loaded by (add in path). Contact your administrator for further assistance.". I have installed required .net framework and Microsoft visual studio 2010 tools for office runtime (Testing machine with windows 7 and office 2010).
Solutions that were created by using Visual Studio 2013 can run in Office 2013, Office 2010, or the 2007 Microsoft Office system. However, the solution can use only those features and APIs that are available in all three versions of Office. You can read more about that in the Running Solutions in Different Versions of Microsoft Office article.
Make sure that you have got the full edition of the .net framework installed, not the Client Profile.
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?