Retrieving the COM class factory for component error while generating word document(生成 Word 文档时检索 COM 类工厂的组件错误)
问题描述
我正在尝试使用大部分代码从 VB.NET 编辑 word 文档:
I am trying to edit a word document from VB.NET using for the most part this code:
如何从 Visual Basic .NET 自动化 Word 以创建新文档http://support.microsoft.com/kb/316383
它在我的机器上运行良好,但是当我发布到服务器时出现以下错误.
It works fine on my machine but when i publish to the server i get the following error.
检索 COM 类工厂具有 CLSID 的组件{000209FF-0000-0000-C000-000000000046}由于以下错误而失败:80070005.
Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005.
说明:在执行过程中发生未处理的异常执行当前的 Web 请求.请查看堆栈跟踪以获取更多信息有关错误和位置的信息它起源于代码.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
异常详情: System.UnauthorizedAccessException:检索 COM 类工厂具有 CLSID 的组件{000209FF-0000-0000-C000-000000000046}由于以下错误而失败:80070005.
Exception Details: System.UnauthorizedAccessException: Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005.
当我尝试只创建一个 word 应用程序对象时发生实际错误
The actual error happens when i try to just create a word application object
Dim oWord As New Word.Application
使用 Visual Studio 2008 和 VB.NET 3.5.我参考了Microsoft Word 10.0 对象库",并在 bin 目录中看到了 Interop.Word.dll 文件.
Using Visual Studio 2008 and VB.NET 3.5. I made a reference to the "Microsoft Word 10.0 Object Library" and i see Interop.Word.dll file in the bin directory.
在开发机器和 Windows Server 2003 上使用 MS Office 2003
Using MS Office 2003 on development machine and Windows Server 2003
对于 .NET 来说还是个新手,对窗口服务器了解不多,但UnauthorizedAccessException"听起来像是权限问题.我想知道是否有人可以指出我可能需要做些什么来让我的小应用程序访问使用 word 的正确方向.
Still fairly new to .NET and don't have much knowledge about window server, but "UnauthorizedAccessException" sounds like a permission issue. I'm wondering if someone could point me in the right direction on what i might need to do to give my little application access to use word.
推荐答案
听起来绝对是权限问题.您是否在 Windows 服务中运行代码?该服务通常作为本地系统运行,它可能没有访问 Word 对象模型的权限.此外,如果 word 已经使用其他用户的凭据运行,那么您的程序可能无法使用不同的凭据通过 COM 访问它.办公应用程序往往是单一实例,这似乎加剧了这个问题.
It definitely sounds like a permissions problem. Are you running your code in a windows service? The service normally runs as Local System, which may not have permission to access the Word object model. Additionally, if word is already running using the credentials of some other user then your program may not be able to access it via COM using different credentials. The office applications tend to be single instance which seems to exacerbate this problem.
这篇关于生成 Word 文档时检索 COM 类工厂的组件错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:生成 Word 文档时检索 COM 类工厂的组件错误
基础教程推荐
- rabbitmq 的 REST API 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- c# Math.Sqrt 实现 2022-01-01