Microsoft Office 互操作程序集参考 [英] Microsoft Office Interop Assembly references

查看:35
本文介绍了Microsoft Office 互操作程序集参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在 Visual Studio 2005 中开发的应用程序,我正在使用 ClickOnce 进行部署.我的解决方案包含两个项目 - 一个用 VB 编码的用户界面层和一个用 C# 编码的类库.我的 C# 类库有一些使用 Outlook 和 Excel 互操作程序集(Microsoft.Office.Interop.Outlook 和 Microsoft.Office.Interop.Excel,版本 11)的代码.这是我的问题.

I have an application developed in Visual Studio 2005 which I am deploying using ClickOnce. My solution contains two projects - a user interface layer coded in VB, and a class library coded in C#. My C# class library has some code that uses the Outlook and Excel Interop Assemblies (Microsoft.Office.Interop.Outlook and Microsoft.Office.Interop.Excel, both version 11). Here are my questions.

  1. 虽然我还没有找到哪里是绝对的,但我的理解是,您必须拥有合适版本的 Office 应用程序 (Outlook/Excel) 才能安装使用 Interop 程序集的应用程序.这是正确的吗?

如果(1. = 是)那么

如果您的应用程序仅将 Interop 程序集用于几个功能,而这些功能将仅被总用户群中的少数几个使用,您将如何处理?如果只有部分用户需要使用这些功能,为什么我必须要求我的应用程序的每个用户都安装 Microsoft Office?这些互操作程序集只是 .dll 文件,所以它们与其他文件的不同之处在于,您不能只将文件与项目一起发布,并且无论安装什么软件都满足参考要求客户端?(显然,我对 GAC 及其对 Visual Studio 行为的影响知之甚少.)我很乐意编写自己的代码来检查是否存在使用它们的少数功能所需的 Office 软件.没有 Office,无法访问功能...

How would you handle the situation in which your application uses the Interop assemblies for only a couple of features that will be utilized by only a select few of the total user base? Why must I require every user of my application to install Microsoft Office if only some users will need to use those features? These Interop assemblies are just .dll files, so what makes them so different from others in that you can't just publish the file with your project and have that satisfy the reference regardless of what software is installed at the client? (Clearly I have a poor understanding of the GAC and it's effect on Visual Studio's behavior.) I would be happy to write my own code to check for the existence of the required Office software for the few features that use them. No Office, no access to feature...

其他

如果我对此的理解不正确,那么我如何设置我的引用和 ClickOnce 设置,以便用户在尝试安装时不会遇到以下错误?

If my understanding on this is incorrect, then HOW do I setup my references and ClickOnce settings so that users don't encounter the following error upon installation attempt?

无法安装或运行该应用程序.该应用程序要求首先在全局程序集缓存 (GAC) 中安装程序集办公室版本 11.0.0.0.

"Unable to install or run the application. The application requires that assembly office Version 11.0.0.0 be installed in the Global Assembly Cache (GAC) first.

请联系您的系统管理员."

Please Contact your system administrator."

  • 我已尝试将 Interop 引用 CopyLocal 属性设置为 True 和 False.
  • 在我的 ClickOnce 应用程序文件列表中,我尝试将这些程序集设置为包含、排除和先决条件.
  • 在我的研究中,我看到有些人将这些引用指向 *C:WINDOWSassemblyGAC*,我的指向 *C:Program FilesMicrosoft Visual Studio 9.0Visual Studio Tools for OfficePIAOffice11* 但我还没有找到更改参考路径的方法.根据 http://msdn.microsoft.com/en-us/library/ez524kew(VS.80).aspx 你不能从 GAC 添加引用,那么其他人是如何管理的?
  • 我尝试将引用从 *C:Program FilesMicrosoft Visual Studio 9.0Visual Studio Tools for OfficePIAOffice11* 复制到我的项目目录并在那里引用它们.
  • I have tried setting my Interop references CopyLocal property to both True and False.
  • In my ClickOnce Application Files list, I have tried setting these assemblies to Include, Exclude and Prerequisite.
  • In my research I have seen where some people have these references pointing to *C:WINDOWSassemblyGAC*, mine points to *C:Program FilesMicrosoft Visual Studio 9.0Visual Studio Tools for OfficePIAOffice11* but I haven't found a way to change the reference path. According to http://msdn.microsoft.com/en-us/library/ez524kew(VS.80).aspx you CAN'T add references from the GAC, so how did other people manage it?
  • I have tried copying the references from *C:Program FilesMicrosoft Visual Studio 9.0Visual Studio Tools for OfficePIAOffice11* to my project directory and referencing them there.

如果结束

我想我需要知道的主要事情是如何/是否可以在我的出版物中包含这些程序集并满足或绕过 GAC 要求.

I suppose the main thing I need to know is how/if I can include these assemblies in my publication and satisfy or bypass the GAC requirement.

在可能的情况下,请尽量直接回答我的具体问题.虽然文章很有帮助,但我已经阅读了很多文章并尝试了很多建议的解决方案,但都没有成功.请记住,我对这一切如何运作的后勤缺乏了解.

Where possible, please try to answer my specific questions as directly as possible. While articles are helpful, I have already read A LOT of articles and tried A LOT of suggested solutions and have found no success. Keep in mind my lack of understanding of the logistics of how this all works to begin with.

请原谅我的不理解,感谢您提供的任何帮助.非常感谢!

Forgive me for my lack of understanding, and thank you for any help you can offer. It is much appreciated!

推荐答案

您可能想看看 NetOffice 项目:http://netoffice.codeplex.com/.

You might like to have a look at the NetOffice project: http://netoffice.codeplex.com/.

它是一套免费(MIT 许可)且完整(所有 2000-2010 版本和所有 Office 应用程序)的独立于版本的互操作程序集.程序集是使用工具从实际 PIA 生成的,因此它们是正确、完整和最新的,并且可能会为未来版本快速更新.

It is a free (MIT License) and complete (all the versions 2000-2010 and all the Office apps) set of version-independent interop assemblies. The assemblies are generated from the actual PIAs with a tool, so they are correct, complete and up-to-date, and likely to be be updated quickly for future versions.

另一个不错的功能是每个成员的 IntelliSense 显示实现该成员的 Office 版本.

Another nice feature is that the IntelliSense for each member displays which Office versions implement that member.

对于部署,您可以随应用一起复制或安装程序集.

For deployment, you can copy or install the assemblies with your app.

这篇关于Microsoft Office 互操作程序集参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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