通过 asp.net 访问 Office Word 对象模型会导致“由于以下错误而失败:80070005 访问被拒绝”。
我开发了一个网站,允许用户上传 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
好的,我通过以下步骤解决了这个问题:
然后 Excel、Word 和其他应用程序就可以工作了,祝你好运。
Ok, I resolved this problem with this steps:
Then Excel, Word and other applications can work, good luck.
这对我有用:
DCOMCNFG
mmc comexp.msc /32
而不是按照 Darkseal 建议的步骤 1 中的
DCOMCNFG
此处)This worked for me:
DCOMCNFG
mmc comexp.msc /32
instead of
DCOMCNFG
on step 1 as suggested by Darkseal here)在安装了 Word 的服务器计算机上的“事件查看器”中的“Windows 日志”、“系统”下查看。您是否看到记录的事件类似于以下内容:
如果是这样,请运行 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:
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).
我很难使用已接受的答案来解决这个问题,因为 Microsoft Word 97 - 2003 Document 记录未在 DCOM 配置项中列出。我在 这篇 Technet 博客文章,他们在其中正确解释了该问题:
并且还建议使用以下命令行命令(而不是
DCOMCNFG
)作为一种有效的修复:强制加载 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:
And also suggested to use the following command-line command (instead of
DCOMCNFG
) as an effective fix: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.
在 DCOM 中找不到 Microsoft Word 应用程序,
如果在具有 32 位 Office 的 64 位系统上
然后
您的 Word 也是 64 位(如果您的 Windows 是))
IIS_IUSRS 可能具有启动和访问权限
并重试
级别”下拉菜单中选择“无”。
If you cannot find Microsoft Word Application in DCOM
On 64 bit system with 32 bit Office try this:
after that
your Word is also 64 bit (if your Windows is))
IIS_IUSRS could have rights for launch and access
and try again
Level" drop down choose "None".
除了上述问题之外,我还遇到了一个问题,我想我应该分享一下,以防其他人也遇到这个问题。
我的.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.