简体   繁体   English

Office互操作:在Office 2007的计算机上使用2003 PIA进行开发

[英]Office interop: developing with 2003 PIAs on a machine with Office 2007

I have Office 2007 on my dev machine. 我的开发机器上有Office 2007。 I have a small app I'm building for a customer server with Office 2003 that needs to do some interop. 我有一个小应用程序,我正在为Office 2003的客户服务器构建,需要进行一些互操作。 My program will run as a scheduled task in a nightly batch process. 我的程序将在夜间批处理过程中作为计划任务运行。

No matter what I do, I can't find the version 11.0 of the Access interop assembly so that will work on the server. 无论我做什么,我都找不到Access互操作程序集的11.0版本,以便在服务器上运行。

I've tried explicitly downloading and installing them on my machine. 我已经尝试在我的机器上明确下载并安装它们。 I tried installing the 2007 interop assemblies on the server (a full Office 2007 install is out of the question). 我尝试在服务器上安装2007互操作程序集(完整的Office 2007安装是不可能的)。 I tried several different COM references. 我尝试了几种不同的COM引用。 I tried looking for the COM object on the server to reference in the visual studio project. 我试图在服务器上寻找COM对象,以便在visual studio项目中引用。 And I've tried too many other little things to list them all here. 而且我已经尝试了太多其他小东西来列出这些。

What's going on here? 这里发生了什么? How can I get this working? 我怎样才能使这个工作?

I've found the only way to do this, even with both versions installed side-by-side, in .Net v2 and above, was to add a reference to the PIA (rather than the COM lib). 我找到了唯一的方法,即使两个版本并排安装在.Net v2及更高版本中,也是为了添加对PIA(而不是COM库)的引用。 Frameork v1.1 would actually bind to the correct version, if they were present side-by-side. Frameork v1.1实际上会绑定到正确的版本,如果它们并排存在的话。

Can't you copy the PIA from the server to your machine (to a local folder) and then add a reference to that copy? 你不能将PIA从服务器复制到你的机器(到本地文件夹),然后添加对该副本的引用吗?

If you like to go another way you could avoid using the PIAs and use ComImport instead. 如果您想采用其他方式,可以避免使用PIA并使用ComImport Andrew Whitechapel has the details in his blog: Andrew Whitechapel在他的博客中有详细信息:

Add-ins for Multiple Office Versions without PIAs 没有PIA的多个Office版本的加载项

Update (from comment): If you can't locate the Access PIA on the server you could try the following: 更新(来自评论):如果您无法在服务器上找到Access PIA,您可以尝试以下方法:

  • Download the Office 2003 PIA setup from here: Office 2003 Update: Redistributable Primary Interop Assemblies 从此处下载Office 2003 PIA设置: Office 2003更新:可再发行的主互操作程序集

  • Extract the self-extracting executable on the command line (/? will list the options): 在命令行中提取自解压可执行文件(/?将列出选项):

     >O2003PIA.exe /C /T:C:\\PIA 
  • Run the extracted MSI with full logging enabled: 运行提取的MSI并启用完整日志记录:

     >msiexec -i O2003PIA.msi /l*vx log.txt 

    and check the log for the Access interop assembly and further hints whether anything went wrong with the installation. 并检查Access互操作程序集的日志,并进一步提示安装是否出现任何问题。 Alternatively to this step you could use an MSI unpacker utility to geth the assembly. 作为此步骤的替代,您可以使用MSI解包器实用程序来进行组装。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Worksheet.Unprotect-Office Interop-2003和2007之间的区别 - Worksheet.Unprotect - Office Interop - Difference between 2003 and 2007 Visual Studio 2008 Office Interop 2003与2007 - Visual Studio 2008 Office Interop 2003 vs 2007 Office 2003互操作仅安装了Office 2010 - Office 2003 interop with only Office 2010 installed 如何在未安装Office的计算机上手动安装Office 2007 PIA? - how can I manually install the Office 2007 PIAs on a computer with no Office installed? Windows Server 2008 ..是否支持Office 2003 interop? - Is Office 2003 interop supported on Windows server 2008 ..? Office 2003:无法找到Microsoft.Office.Interop.Powerpoint dll - Office 2003: Unable to find Microsoft.Office.Interop.Powerpoint dll .NET框架和Office 2007中的Office 2003 PIA先决条件 - Office 2003 PIA Prerequisite in the .Net framework and Office 2007 Office 2003互操作问题,界面,方法未找到 - Office 2003 interop problems, interface, method not found Office 2007的主要互操作程序集(PIA)-32/64位? - Primary Interop Assemblies (PIA) for Office 2007 - 32/64bit? 使用Outlook interop的OpenSharedItem会在Office 2003中引发异常异常,与Office 2008一起使用 - OpenSharedItem with Outlook interop throws odd exception with Office 2003, works with Office 2008
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM