Microsoft Office Interop Assembly参考 [英] Microsoft Office Interop Assembly references

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

问题描述

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


  1. 虽然我没有发现这是绝对的,我的理解是你必须有适当的Office应用程序(Outlook / Excel)的版本,以便安装使用Interop程序集的应用程序。这是正确的吗?

如果(1. =是)然后



如何处理您的应用程序使用Interop程序集只有几个功能的情况,这些功能将仅由总用户数量的少数用户使用?如果只有一些用户需要使用这些功能,为什么我需要我的应用程序的每个用户安装Microsoft Office?这些Interop程序集只是 .dll 文件,所以它们与其他程序的区别很大,因为你不能只在项目中发布文件,而且不管什么软件都安装在客户端? (显然,我对GAC的理解很差,这对Visual Studio的行为有影响)。我很乐意编写自己的代码来检查使用它们的几个功能所需的Office软件的存在。没有办公室,无法访问功能...



否则



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



无法安装或运行应用程序,应用程序要求,组装Office版本11.0.0.0首先安装在全局程序集缓存(GAC)中。



请与系统管理员联系。 p>


  • 我已经尝试将我的Interop引用CopyLocal属性设置为True和False。

  • 在我的ClickOnce应用程序文件列表中,我已经尝试将这些程序集设置为Include,Exclude和Prerequisite。

  • 在我的研究中,我看到有些人有这些参考指向* C:\WINDOWS\assembly\GAC *,我的点指向* C:\Program Files\\ \\ Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office11 *但我还没有找到一种方法来更改参考路径。根据 http://msdn.microsoft.com/en -us / library / ez524kew(VS.80).aspx 你不能从GAC添加引用,那么其他人如何管理它?

  • 我试过复制来自* C:\Program Files\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office11 *到我的项目目录中并引用它们的引用。



结束如果



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



尽可能地请尽可能直接回答我的具体问题。虽然文章是有帮助的,我已经阅读了大量的文章,并尝试了大量的建议的解决方案,并没有发现没有成功。请记住,我对物流方面的了解不足以开始。



原谅我,因为我缺乏理解,感谢您提供任何帮助提供。非常感谢!

解决方案

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



这是一个免费的许可证)和完整版(所有版本2000-2010和所有Office应用程序)版本无关的互操作程序集。这些程序集是由具有工具的实际PIA生成的,因此它们是正确的,完整的和最新的,并且可能会在将来的版本中快速更新。



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



对于部署,您可以使用应用程序复制或安装程序集。 p>

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. Although I haven't found where this is stated as an absolute, my understanding is that you MUST have the appropriate versions of the Office applications (Outlook/Excel) in order to install an application that uses the Interop assemblies. Is this correct?

If (1. = Yes) Then

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...

Else

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?

"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."

  • 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:\WINDOWS\assembly\GAC*, mine points to *C:\Program Files\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office11* 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 Files\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office11* to my project directory and referencing them there.

End If

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!

解决方案

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

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.

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 Interop Assembly参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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