I have an outlook addin developed with VS 2008 and for 3.5 framework.Now, I want to upgrade it to latest framework(4.6.1).But when I tried to create an office project in VS 2012 targeting 4.6.1 framework.It only showed me office 2010 template.So, is it not possible to develop a VSTO 2007 addin which targets 4.6.1 framework?I want to stick with VSTO 2007 because it is guaranteed to run on all office versions up to office 2016, as my current addin which targets .net 3.5 does.Whereas if I develop an office 2010 addin, it might crash on office 2007.So, please let me know a way to develop an office addin, which is supported by all office versions and targets .net framework 4.6.1.
问题:
回答1:
You want to develop your addin against .NET Framework 4.6.1 but still target Office 2007 as Office is considered to be always 'downward compatible'. Although it theoretically is the case, in real practice you will run into issues (for instance Excel changed its application model from MDI to SDI over time, resulting in all sorts of visibility issues in addins targeting the older versions).
The same goes for the .NET Framework. Applications targeting a lower framework should work with later frameworks. The other way around can cause real issues.
So the best answer in my opinion is to use the lowest denominator in both Office PIA and .NET framework to support the older Office versions. In theory that means you should stay with Office 2007 PIA's and .NET 3.5 for the best compatibility for all Office versions from 2007 and up. In this case there is however still the risk of mismatches as I explained in the first paragraph.
In general you can however mix and match many versions if you only address the Interfaces available in the oldest Office versions, use late binding in special cases.
The 'official' answer from Microsoft has always been, related to VSTO projects, that only two Office versions are supported with each VSTO version, and that has (again) to do with what already was mentioned before. More information on this can be found here: https://msdn.microsoft.com/en-us/library/bb772080(v=vs.120).aspx