.net 无法调试或运行 Word 插件,因为未安装所需的 Microsoft Office 版本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18250511/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cannot debug or run Word AddIn because the required version of Microsoft Office is not installed
提问by sdds
I need to work on an existing Word 2007 addIn project that's a part of a MSVS 2008 solution. However, when I try to debug the addIn, I get the following error message: "You cannot debug or run this project, because the required version of the Microsoft Office application is not installed". I have Office 2007 installed.
我需要处理现有的 Word 2007 插件项目,该项目是 MSVS 2008 解决方案的一部分。但是,当我尝试调试插件时,收到以下错误消息:“您无法调试或运行此项目,因为未安装所需版本的 Microsoft Office 应用程序”。我安装了 Office 2007。
I tried creating a new Word 2007 addIn project in the same solution, and I have no problem debugging it. As far as I can tell, all the referenced Office assemblies are the same between these two projects.
我尝试在同一个解决方案中创建一个新的 Word 2007 addIn 项目,并且调试它没有问题。据我所知,这两个项目之间所有引用的 Office 程序集都是相同的。
Referenced Office assemblies:
引用的 Office 程序集:
Microsoft.Office.Interop.Word (c:\Program Files (x86)\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office12\Microsoft.Office.Interop.Word.dll)
Microsoft.Office.Tools.Common.v9.0 (c:\Program Files (x86)\Reference Assemblies\Microsoft\VSTO\v9.0\Microsoft.Office.Tools.Common.v9.0.dll)
Microsoft.Office.Tools.v9.0 (c:\Program Files (x86)\Reference Assemblies\Microsoft\VSTO\v9.0\Microsoft.Office.Tools.v9.0.dll)
Microsoft.Office.Tools.Word.v9.0 (c:\Program Files (x86)\Reference Assemblies\Microsoft\VSTO\v9.0\Microsoft.Office.Tools.Word.v9.0.dll)
Office (c:\Program Files (x86)\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office12\Office.dll)
stdole c:\Program Files (x86)\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office11\stdole.dll
Microsoft.Office.Interop.Word (c:\Program Files (x86)\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office12\Microsoft.Office.Interop.Word.dll)
Microsoft.Office.Tools.Common.v9.0 (c:\Program Files (x86)\Reference Assemblies\Microsoft\VSTO\v9.0\Microsoft.Office.Tools.Common.v9.0.dll)
Microsoft.Office.Tools.v9.0 (c:\Program Files (x86)\Reference Assemblies\Microsoft\VSTO\v9.0\Microsoft.Office.Tools.v9.0.dll)
Microsoft.Office.Tools.Word.v9.0 (c:\Program Files (x86)\Reference Assemblies\Microsoft\VSTO\v9.0\Microsoft.Office.Tools.Word.v9.0.dll)
Office (c:\Program Files (x86)\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office12\Office.dll)
stdole c:\Program Files (x86)\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office11\stdole.dll
I tried rebuilding, starting debug under both Debug and Release configurations. Nothing helps. What else am I missing that could cause a problem with debugging the old project?
我尝试重建,在 Debug 和 Release 配置下开始调试。没有任何帮助。我还缺少什么可能会导致调试旧项目出现问题?
回答by sdds
Apparently, when the addin project is created, debug information such as the MS Officeversion and the executable path used for debugging is saved in the .CSPROJ file.
显然,在创建插件项目时,MS Office版本和用于调试的可执行路径等调试信息保存在 .CSPROJ 文件中。
So debug is not guaranteed to work on another machine.
所以调试不能保证在另一台机器上工作。
This information is saved in following XML node of the project file:
此信息保存在项目文件的以下 XML 节点中:
ProjectExtensions \ VisualStudio \ FlavorProperties \ ProjectProperties
ProjectExtensions \ VisualStudio \ FlavorProperties \ ProjectProperties
In my case, the problem was in the attributes
就我而言,问题出在属性上
OfficeVersion="14.0"DebugInfoExeName="#Software\Microsoft\Office\14.0\Word\InstallRoot\Path#WINWORD.EXE"
OfficeVersion="14.0"DebugInfoExeName="#Software\Microsoft\Office\14.0\Word\InstallRoot\Path#WINWORD.EXE"
Changing 14.0 to 12.0 (2010 to 2007) in their values solved my problem.
将 14.0 更改为 12.0(2010 年到 2007 年)的值解决了我的问题。
Check out these questions for reference:
查看这些问题以供参考:
回答by HockeyJ
For the benefit of searchers, I hit this error in Visual Studio despite referencing the correct version in the section mentioned by @sdds.
为了搜索者的利益,尽管在@sdds 提到的部分中引用了正确的版本,但我还是在 Visual Studio 中遇到了这个错误。
For me the fix was:
对我来说,修复是:
- Go to the project properties in visual studio
- Go to the 'Debug' tab
- Click the 'Start External Program' radiobutton
- Enter the path to the Office Application e.g. C:\Program Files\Microsoft Office 15\root\office15\winword.exe
- Run the project.
- 转到visual studio中的项目属性
- 转到“调试”选项卡
- 单击“启动外部程序”单选按钮
- 输入 Office 应用程序的路径,例如 C:\Program Files\Microsoft Office 15\root\office15\winword.exe
- 运行项目。
回答by Doicare
I had the same issue, I changed the officeversion attribute & I had to install office 2010 with the currently installed office 2013
我遇到了同样的问题,我更改了 officeversion 属性,并且必须使用当前安装的 office 2013 安装 office 2010

