添加Excel 2010参考 [英] Add excel 2010 reference

查看:117
本文介绍了添加Excel 2010参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我的C#项目,我从Office 2010安装的计算机中的com组件中添加了Microsoft Excel 14库.之后,我在Office 2003安装的计算机上构建了相同的项目.我复制了"Microsoft.Office.Interop.Excel.dll",从Office 2010安装的计算机中添加,并从Office 2003安装的计算机中添加为参考.但是然后我在构建时遇到2个错误

1.

错误145程序集``Microsoft.Office.Interop.Excel,版本= 14.0.0.0,文化=中性,PublicKeyToken = 71e9bce111e9429c''使用``Microsoft.Vbe.Interop,版本= 14.0.0.0,文化=中性,PublicKeyToken = 71e9bce111e9429c ''具有比引用程序集更高的版本``Microsoft.Vbe.Interop,Version = 11.0.0.0,Culture = neutral,PublicKeyToken = 71e9bce111e9429c''d:\ References \ Microsoft.Office.Interop.Excel.dll UI

2.

错误146程序集``Microsoft.Office.Interop.Excel,版本= 14.0.0.0,文化=中性,PublicKeyToken = 71e9bce111e9429c''使用的``办公室,版本= 14.0.0.0,文化=中性,PublicKeyToken = 71e9bce111e9429c''高于参考程序集的版本``office,Version = 11.0.0.0,Culture = neutral,PublicKeyToken = 71e9bce111e9429c''d:\ References \ Microsoft.Office.Interop.Excel.dll

For my c# project I added Microsoft Excel 14 library from com component in office 2010 installed computer. After that I built the same project on office 2003 installed computer. I copied "Microsoft.Office.Interop.Excel.dll" from office 2010 installed coputer and add as the reference from office 2003 installed computer. But then I''m getting 2 errors when build

1.

Error 145 Assembly ''Microsoft.Office.Interop.Excel, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'' uses ''Microsoft.Vbe.Interop, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'' which has a higher version than referenced assembly ''Microsoft.Vbe.Interop, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'' d:\References\Microsoft.Office.Interop.Excel.dll UI

2.

Error 146 Assembly ''Microsoft.Office.Interop.Excel, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'' uses ''office, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'' which has a higher version than referenced assembly ''office, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'' d:\References\Microsoft.Office.Interop.Excel.dll

推荐答案

好像您引用了'03 dll,但复制了'10 dll.这就是错误的意思.我想,只是不要这样做?
Looks like you referenced the ''03 dll, but copied over the ''10 dll. That''s what the error is saying. I guess, just don''t do that?


您将无法运行或编译到未安装Office 2010的计算机中.

这是因为在安装Office时,Interop.Excel进入了GAC.

1)重新安装Office 2010并选择添加或删除功能"

2)确保在"Microsoft Excel"下,打开".NET可编程性支持"功能.

这将在目标计算机上的GAC中安装Microsoft.Office.Interop.Excel版本14.0.0.0.
You are not going to be able to run or compile into a machine that does not have Office 2010 installed.

That is because Interop.Excel get into the GAC when Office is installed.

1) Re-Install Office 2010 & select ''Add or Remove features''

2) Under ''Microsoft Excel'', make sure you turn on the ''.NET Programmability Support'' feature.

This will install the Microsoft.Office.Interop.Excel Version 14.0.0.0 in the GAC on the Target machine.


这篇关于添加Excel 2010参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆