Office 2003:找不到 Microsoft.Office.Interop.Powerpoint dll

发布于 2024-08-16 09:49:48 字数 507 浏览 1 评论 0原文

我创建了一个 Windows 应用程序,它使用 Microsoft Office 2003 的 Office.dllPowerPoint dll。在设计时,当我将对这些 dll 的引用添加到我的项目时它引用以下路径:

C:\WINDOWS\ assembly\GAC\Microsoft.Office.Interop.PowerPoint\

该应用程序在开发它的计算机上运行完美,但是当我尝试在其上运行它时其他机器失败。它抛出的异常是:

System.Reflection.TargetInitationException:调用目标已引发异常。 ---> System.IO.FileNotFoundException

我试图在我的测试机器上找到上述路径,但令我惊讶的是,尽管安装了office 2003和2007(2台不同的机器),但那里不存在该文件夹。

有人可以帮我解决这个问题吗?

I have created a windows application which makes use of Office.dll and PowerPoint dlls of Microsoft office 2003. At design time, when I am adding reference to these dlls to my project it refers following path:

C:\WINDOWS\assembly\GAC\Microsoft.Office.Interop.PowerPoint\

The application runs perfect on the machine where it is developed, but when I am trying to run it on other machine it fails. The exception it is throwing is:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException

I tried to locate the above path on my test machine, but I am surprised that, though office 2003 and 2007 is installed (2 different machines), this folder is not present over there.

Can anybody help me resolving this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

尐籹人 2024-08-23 09:49:48

1.Office 2003 Primary Interop Assemblies (PIA) 可再发行组件是一个 Microsoft Windows Installer 程序包,其中包含 Microsoft Office 2003 产品的 Primary Interop Assemblies,您可以从 此处 它包含您需要的程序集

2.您可以将“设置为 true”在项目引用属性中复制此程序集的“本地”键,在这种情况下,它将被复制到项目的输出文件夹中

3. 您实际上并不需要它来使用 MS Office 应用程序,尽管它使操作变得更容易。下面是一个如何在没有互操作类的情况下打开演示文稿的示例

Type officeType = Type.GetTypeFromProgID("PowerPoint.Application");
object officeInstance = Activator.CreateInstance(officeType);
// set visible
object value = -1;
officeType.InvokeMember("Visible", BindingFlags.SetProperty, null, officeInstance, new object[] { value });
// open presenation
object objTrue = -1;
object objFalse = 0;
object fileNameObj = presentation_file_name;
object documents = officeType.InvokeMember("Presentations", BindingFlags.GetProperty, null, officeInstance, null);
documents.GetType().InvokeMember("Open", BindingFlags.InvokeMethod, null, documents, new object[] { fileNameObj, objTrue, objFalse, objTrue });

,没有测试这个确切的类,但是像这样的东西对我来说效果很好,问候

1.There is an Office 2003 Primary Interop Assemblies (PIA) redistributable is a Microsoft Windows Installer package that contains the Primary Interop Assemblies for Microsoft Office 2003 products you can get it from here it includes an assembly you need

2.You can set true to the "Copy Local" key for this assembly in your project references properties, in this case it would be copied into the output folder of your project

3.You don't really need it to work with MS Office applications, though it makes it easier. Below is an example of how you can open a presentation without interop classes

Type officeType = Type.GetTypeFromProgID("PowerPoint.Application");
object officeInstance = Activator.CreateInstance(officeType);
// set visible
object value = -1;
officeType.InvokeMember("Visible", BindingFlags.SetProperty, null, officeInstance, new object[] { value });
// open presenation
object objTrue = -1;
object objFalse = 0;
object fileNameObj = presentation_file_name;
object documents = officeType.InvokeMember("Presentations", BindingFlags.GetProperty, null, officeInstance, null);
documents.GetType().InvokeMember("Open", BindingFlags.InvokeMethod, null, documents, new object[] { fileNameObj, objTrue, objFalse, objTrue });

didn't test this exact one, but smth like this works fine for me, regards

说不完的你爱 2024-08-23 09:49:48

您正在寻找的互操作 dll 已安装在 GAC 中的开发计算机上。因此,它不是标准部署的一部分。您需要手动复制它。

另一种选择(可能是更干净的选择)是在目标计算机上运行 Office 安装并让它安装所有必需的内容。只需确保您选择了正确的选项

The interop dll you are looking for is installled on your deevelopment machine in the GAC. As such it is not a part of the standard deployment. You need to copy it over by hand.

Another option (and may be a cleaner one) would be to run the Office installation on the target machine and let it install all what's necessary. Just make sure that you selected proper options

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文