在生成Word文档时检索COM类工厂以查找组件错误 [英] Retrieving the COM class factory for component error while generating word document

查看:508
本文介绍了在生成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.


使用CLSID
检索
组件的COM类工厂{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.

当我尝试创建一个单词应用程序对象时,发生实际错误

The actual error happens when i try to just create a word application object

 Dim oWord As New Word.Application


b $ b

使用Visual Studio 2008和VB.NET 3.5。我参考了Microsoft Word 10.0对象库,我看到Interop.Word.dll文件在bin目录。

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

t有很多关于窗口服务器的知识,但UnauthorizedAccessException听起来像一个权限问题。我想知道,如果有人可以指出我在正确的方向,我可能需要做,给我的小应用程序访问使用单词。

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类工厂以查找组件错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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