PIA已安装但仍收到互操作错误 [英] PIA's Installed but still receiving interop error

查看:96
本文介绍了PIA已安装但仍收到互操作错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Microsoft.Office.Interop.xxxxxxx命名空间,但Visual Studio 2010不提供"interop"选项.我已经为office12和office14安装了PIA,已经将它们包括在解决方案资源管理器的参考"中,但是它不起作用.

I am trying to use the Microsoft.Office.Interop.xxxxxxx namespace but Visual Studio 2010 is not providing an option for "interop". I have the PIA's installed for office12 and office14, I have included them in the 'References' in the Solution Explorer, but it is not working.

我要用来调用名称空间的代码是:

The code I am trying to call the namespace with is:

    using Excel = Microsoft.Office...;

在"Office."之后,仅提供"Core"选项.所以看起来像这样

After "Office.", I am only given the option for "Core". So it would look like this

    using Excel = Microsoft.Office.Core;

这与导入的引用匹配...但是使用此命名空间似乎没有用.

This matches the reference that was imported...but using this namespace does not seem to be useful.

我的问题是如何使Microsoft.Office.Interop选项被接受并以智能感知方式显示?

My question is how do I get the Microsoft.Office.Interop option to be accepted and display in intellisense?

示例:

    using Excel = Microsoft.Office.Interop.Excel;

收到"Interop"的错误消息= 类型或名称空间名称'Interop'在名称空间'Microsoft.Office'中不存在(您是否缺少程序集引用?)

Error message being received for 'Interop'= "The type or namespace name 'Interop' does not exist in the namespace 'Microsoft.Office' (are you missing an assembly reference?)

我在解决方案资源管理器中加载的程序集是"Microsoft Office 14.0对象库" TypeLib版本2.5.程序集路径="C:\ Program Files \ Common Files \ Microsoft Shared \ OFFICE14 \ MSO.DLL

The assembly that I loaded in the Solution Explorer is "Microsoft Office 14.0 Object Library" TypeLib Version 2.5. The assembly path = "C:\Program Files\Common Files\Microsoft Shared\OFFICE14\MSO.DLL

谢谢您的建议!

推荐答案

您没有选择正确的参考.改为使用"Microsoft Excel 14.0对象库".

You didn't pick the correct reference. Use "Microsoft Excel 14.0 Object Library" instead.

请注意,VS2010支持Embed Interop Types属性作为程序集引用.您确实希望将其用于Office应用程序,而无需PIA.它会自动设置为True.

Note that VS2010 supports the Embed Interop Types property for an assembly reference. You really want to use that for an Office app, no PIA required. It is automatically set to True.

这篇关于PIA已安装但仍收到互操作错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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