通过 asp.net 访问 Office Word 对象模型会导致“由于以下错误而失败:80070005 访问被拒绝”。

发布于 2024-09-14 05:18:11 字数 730 浏览 6 评论 0原文

我开发了一个网站,允许用户上传 Office 文档,然后使用 Office 对象模型将文档转换为 HTML 文件,然后将其显示在 iFrame 中。

当然,我已经包含了对 Office.interop.word 的引用,并且该网站在我的开发计算机上运行良好。当我将其上传到生产服务器时,该网站功能正常,直到我尝试上传文档。我最初收到类似的错误,指出“COM 对象未注册”。我意识到我的生产服务器上没有安装 Word。因此,我安装了 word,现在当服务器尝试访问 word 对象模型时,我收到以下错误:

正在检索 CLSID 为 {000209FF-0000-0000-C000- 的组件的 COM 类工厂000000000046} 由于以下错误而失败:80070005 访问被拒绝。 (HRESULT 异常:0x80070005 (E_ACCESSDENIED))

我在注册表中搜索了相应的 CLSID,并找到了相应的文件夹。我向 IUSR_ 帐户添加了完全控制权,由于错误持续存在,我最终向“所有人”添加了完全控制权,并确保这些权限继承到文件夹的其余部分。然后,我向 IUSR_ 添加了完全控制权,并最终再次向我的 Microsoft Office 文件夹中的“每个人”添加了完全控制权。

不知道要授予哪些其他权限以及在哪里才能消除此“访问被拒绝”错误。我必须在错误的位置授予它们,因为据我所知我不能比“每个人”“完全控制”更宽容了。

任何人都可以阐明吗?

I have developed a website that allows users to upload office documents then uses the office object model to convert the document to an HTML file that it then displays in an iFrame.

I have, of course, included references to Office.interop.word, and the site works fine on my development machine. When I uploaded it to my production server the site functions fine until I try to upload a document. I initially got a similar error that said "COM object not registered". I realized that Word wasn't installed on my production server. So I installed word and now when the server tries to access the word object model I receive the following error:

Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

I searched the registry for the corresponding CLSID and found a corresponding folder. I added full control to the IUSR_ account and due to the persistence of the error I eventually added full control to "everyone" and ensured these permissions inherited down to the rest of the folder. I then added full control to IUSR_ and again eventually added full control to "everyone" to my microsoft office folder.

I don't know what other permissions to grant and where in order to make this "Access is denied" error go away. I must be granting them in the wrong place, because as far as I know I can't be any more permissive than "Everyone" "Full Control".

Can anyone shed any light?

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

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

发布评论

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

评论(6

束缚m 2024-09-21 05:18:11

好的,我通过以下步骤解决了这个问题:

  1. 在命令行中输入 DCOMCNFG
  2. Expand Console Root >组件服务>计算机,右键单击我的电脑,然后
  3. 在选项卡中选择属性 COM 安全 >启动和激活权限 单击编辑默认值
  4. 添加用户(例如 IIS_IUSRS)或服务
  5. 选中允许本地启动和本地激活

然后 Excel、Word 和其他应用程序就可以工作了,祝你好运。

Ok, I resolved this problem with this steps:

  1. In the command line put DCOMCNFG
  2. Expand Console Root > Component Service > Computers, right-click on My Computer, And Select Properties
  3. In the Tab COM Security > Launch and Activation Permissions Click in Edit Default
  4. Add the User (Ex. IIS_IUSRS) or service
  5. Check Allow Local Launch and Local Activation

Then Excel, Word and other applications can work, good luck.

甜柠檬 2024-09-21 05:18:11

这对我有用:

  1. 在命令行中输入 DCOMCNFG
  2. Component Services ->计算机 ->我的电脑 -> DCOM 配置
  3. 查找“Microsoft Word 97 - 2003 文档”(如果缺少,请检查您的 Word 是否也是 64 位(如果您的 Windows 是)如果未运行 mmc comexp.msc /32
    而不是按照 Darkseal 建议的步骤 1 中的 DCOMCNFG 此处
  4. 右键单击 ->属性
  5. 转到“安全”选项卡并编辑“自定义”单选按钮,以便 IIS_IUSRS 有权启动和访问
  6. 转到“身份”选项卡并选择“交互式用户”
  7. 应用更改并重试
  8. 如果这一切都失败,还转到选项卡“常规”,然后在“身份验证级别”下拉列表中选择“无”。

This worked for me:

  1. In the command line put DCOMCNFG
  2. Component Services -> Computers -> My Computer -> DCOM Config
  3. Find "Microsoft Word 97 - 2003 Document" (If it is missing check if your Word is also 64 bit (if your Windows is) if it is not run mmc comexp.msc /32
    instead of DCOMCNFG on step 1 as suggested by Darkseal here)
  4. Right click -> Properties
  5. Go To Tab Security and Edit the "Customize" radio buttons so that IIS_IUSRS could have rights for launch and access
  6. Go to Tab Identity and choose "The interactive user"
  7. Apply changes and try again
  8. If all this fails, go also to tab "General" and in "Authentication Level" drop down choose "None".
故事和酒 2024-09-21 05:18:11

在安装了 Word 的服务器计算机上的“事件查看器”中的“Windows 日志”、“系统”下查看。您是否看到记录的事件类似于以下内容:

机器默认权限
设置不授予本地激活
COM 服务器的权限
具有 CLSID 的应用程序
{148BEE7F-6123-41EE-8CCA-E390902BD0D8}
到用户 SomeMachine\SomeUser SID
(S-1-5-21-483881670-2168941642-1987552629-1003) 来自地址 LocalHost (使用 LRPC)。
该安全权限可以是
使用组件服务进行修改
管理工具。

如果是这样,请运行 DCOMCNFG.EXE,然后转到“组件服务”、“计算机”、“我的电脑”(或任何名称)、“DCOM 配置”(如果它询问您是否要修复任何内容,您可以回答“否”)以及事件日志是否消息用于应用程序,然后通过事件日志消息中的名称(此处为项目名称)查找它,如果事件日志消息用于 CLSID(如上面的示例),则通过以下方式查找它: CLSID“{148B...}”(这只是我粘贴的随机 CLSID - 可能会与上面的 000209FF... 匹配),然后选择“更多操作...属性”,进入“安全”选项卡。

在这里,您可以选择 [x] 自定义,然后选择编辑,为相应的用户帐户添加权限,以激活和访问所需的 DCOM 应用程序或类。

这只是一个猜测,但请尝试一下,或者类似的操作(即通过 DCOMCNFG 授予对 CLSID 的访问权限)。

Look in the Event Viewer, under Windows Logs, System, on the server machine where Word is installed. Do you see an event logged that reads something similar to:

The machine-default permission
settings do not grant Local Activation
permission for the COM Server
application with CLSID
{148BEE7F-6123-41EE-8CCA-E390902BD0D8}
to the user SomeMachine\SomeUser SID
(S-1-5-21-483881670-2168941642-1987552629-1003) from address LocalHost (Using LRPC).
This security permission can be
modified using the Component Services
administrative tool.

If so, run DCOMCNFG.EXE, and go to Component Services, Computers, My Computer (or whatever name), DCOM Config (and you can just answer "No" if it asks if you want to fix anything) and if the event log message is for an application, then find it by the name in the event log message, here by item name, and if the event log message is for a CLSID (like the example above) then find it by the CLSID "{148B...}" (that's just a random CLSID I pasted in -- probably it will match your 000209FF... above), and select More actions... Properties, to the Security tab.

Here, you can select [x] Customize and then Edit, to add permission for the appropriate user account to activate and access the required DCOM application or class.

It's just a guess, but give that a try, or something along these lines (i.e. granting access to the CLSID via DCOMCNFG).

花之痕靓丽 2024-09-21 05:18:11

我很难使用已接受的答案来解决这个问题,因为 Microsoft Word 97 - 2003 Document 记录未在 DCOM 配置项中列出。我在 这篇 Technet 博客文章,他们在其中正确解释了该问题:

需要注意的是,如果您安装 32 位 Microsoft Office
64位机器,您可能需要使用32位DCOM配置管理器
查看程序,具体取决于您的操作系统。

在从 Windows XP 到 Windows Server 2008 的 x64 操作系统上,
64 位版本的 DCOMCNFG.EXE 无法正确配置 32 位
用于远程激活的 DCOM 应用程序。这种行为会导致
旨在远程激活的组件,而不是
本地激活。此行为不会出现在 Windows 7 和
Windows Server 2008 R2 及更高版本。

参考号:
http://msdn.microsoft .com/en-us/library/windows/desktop/ms678426(v=vs.85).aspx

并且还建议使用以下命令行命令(而不是 DCOMCNFG)作为一种有效的修复:

mmc comexp.msc /32

强制加载 32 位 DCOM 配置管理器而不是 64 位配置管理器,并允许执行接受的答案中描述的步骤。如果这仍然不起作用,本文还解释了许多其他可能的解决方法。

有关此主题的更多信息,您还可以 在我的博客上阅读这篇文章

I had my hard times figuring this out using the accepted answer, because the Microsoft Word 97 - 2003 Document record wasn't listed among DCOM Config items. I found the solution in this Technet blog post, where they correctly explained the issue:

It’s important to note that if you install 32-bit Microsoft Office on
a 64-bit machine, you may need to use the 32-bit DCOM config manager
to view the programs, depending on your operating system.

On x64 operating systems from Windows XP to Windows Server 2008, the
64-bit version of DCOMCNFG.EXE does not correctly configure 32-bit
DCOM applications for remote activation. This behavior causes
components that are meant to be activated remotely instead being
activated locally. This behavior does not occur in Windows 7 and
Windows Server 2008 R2 and higher versions.

Ref.:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms678426(v=vs.85).aspx

And also suggested to use the following command-line command (instead of DCOMCNFG) as an effective fix:

mmc comexp.msc /32

Which forces loading the 32-bit DCOM config manager instead of the 64-bit one and allows to perform the steps described within the accepted answer. If this still doesn't work, the article also explains a number of other possible workarounds.

For further info regarding this topic, you can also read this post on my blog.

那请放手 2024-09-21 05:18:11

在 DCOM 中找不到 Microsoft Word 应用程序,

如果在具有 32 位 Office 的 64 位系统上

  1. 请尝试以下操作:列出项目
  2. 开始
  3. 运行
  4. mmc-32
  5. 文件
  6. 添加 删除管理单元
  7. 组件服务
  8. 添加
  9. OK
  10. 控制台 根
  11. 组件服务
  12. 计算机
  13. 我的电脑
  14. DCOM 配置

然后

  1. 查找“ Microsoft Word 97 - 2003 文档”(如果缺少,请检查是否
    您的 Word 也是 64 位(如果您的 Windows 是))
  2. 右键单击 ->属性
  3. 转到选项卡安全并编辑“自定义”单选按钮,以便
    IIS_IUSRS 可能具有启动和访问权限
  4. 转到“身份”选项卡并选择“交互式用户”应用更改
    并重试
  5. 如果这一切都失败了,也请转到“常规”选项卡和“身份验证”中
    级别”下拉菜单中选择“无”。

If you cannot find Microsoft Word Application in DCOM

On 64 bit system with 32 bit Office try this:

  1. List item
  2. Start
  3. Run
  4. mmc-32
  5. File
  6. Add Remove Snap-in
  7. Component Services
  8. Add
  9. OK
  10. Console Root
  11. Component Services
  12. Computers
  13. My Computer
  14. DCOM Config

after that

  1. Find "Microsoft Word 97 - 2003 Document" (If it is missing check if
    your Word is also 64 bit (if your Windows is))
  2. Right click -> Properties
  3. Go To Tab Security and Edit the "Customize" radio buttons so that
    IIS_IUSRS could have rights for launch and access
  4. Go to Tab Identity and choose "The interactive user" Apply changes
    and try again
  5. If all this fails, go also to tab "General" and in "Authentication
    Level" drop down choose "None".
挽清梦 2024-09-21 05:18:11

除了上述问题之外,我还遇到了一个问题,我想我应该分享一下,以防其他人也遇到这个问题。

我的.net应用程序使用interop的应用程序池用户已添加到Admin中,但由于iis缓存环境而未生效。执行上述操作以及 iisreset 以反映应用程序池用户的正确管理状态后,一切正常。

In addition to the above, I encountered an issue that I thought I'd share in case other people run into it as well.

The application pool user of my .net app that was using interop was added to Admin but did not take effect due to iis caching environment. After performing the above in addition to an iisreset to reflect proper admin status of the app pool user, everything worked fine.

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