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

时间:2021-07-18 15:57:30

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.

我开发了一个网站,允许用户上传办公文档,然后使用office对象模型将文档转换成HTML文件,然后在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:

当然,我已经包含了对Office.interop.word的引用,并且这个站点在我的开发机器上运行良好。当我将它上传到我的产品服务器上时,站点的功能很好,直到我尝试上载一个文档。我最初得到一个类似的错误,说“COM对象未注册”。我意识到我的产品服务器上没有安装Word。所以我安装了word,现在当服务器试图访问word对象模型时,我收到了以下错误:

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))

使用CLSID {000209ff -000000000 -000 -000000000046}来检索COM类工厂,由于以下错误导致:80070005访问被拒绝。(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.

我在注册表中查找相应的CLSID,并找到了相应的文件夹。我向IUSR_帐户添加了完全控制,由于错误的持久性,我最终向“everyone”添加了完全控制,并确保这些权限继承到文件夹的其余部分。然后我向IUSR_添加了完全控制,并最终将完全控制添加到我的microsoft office文件夹“everyone”。

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?

谁能给我一点启示吗?

5 个解决方案

#1


28  

This worked for me:

这工作对我来说:

  1. In the command line put DCOMCNFG
  2. 在命令行中放置DCOMCNFG
  3. Component Services -> Computers -> My Computer -> DCOM Config
  4. 组件服务->计算机->我的计算机-> DCOM配置
  5. 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)
  6. 查找“Microsoft Word 97 - 2003文档”(如果缺少,请检查您的Word是否也是64位(如果您的Windows是),如果它没有运行mmc comexp。msc /32代替DCOMCNFG在步骤1中(暗黑这里建议)
  7. Right click -> Properties
  8. 点击右键- >属性
  9. Go To Tab Security and Edit the "Customize" radio buttons so that IIS_IUSRS could have rights for launch and access
  10. 转到Tab Security并编辑“自定义”单选按钮,以便IIS_IUSRS可以有启动和访问的权限
  11. Go to Tab Identity and choose "The interactive user"
  12. 进入标签标识,选择“交互用户”
  13. Apply changes and try again
  14. 应用更改并再次尝试
  15. If all this fails, go also to tab "General" and in "Authentication Level" drop down choose "None".
  16. 如果这一切都失败了,也转到tab“General”,在“身份验证级别”下拉菜单中选择“None”。

#2


58  

Ok, I resolved this problem with this steps:

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

  1. In the command line put DCOMCNFG
  2. 在命令行中放置DCOMCNFG
  3. Expand Console Root > Component Service > Computers, right-click on My Computer, And Select Properties
  4. 扩展控制台根>组件服务>计算机,右键单击我的计算机,并选择Properties。
  5. In the Tab COM Security > Launch and Activation Permissions Click in Edit Default
  6. 在选项卡COM安全>启动和激活权限中,单击“编辑默认”
  7. Add the User (Ex. IIS_IUSRS) or service
  8. 添加用户(例如IIS_IUSRS)或服务
  9. Check Allow Local Launch and Local Activation
  10. 检查允许本地启动和本地激活。

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

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

#3


11  

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:

查看事件查看器,在Windows日志、系统、安装Word的服务器机器上。您是否看到一个事件被记录下来,其内容类似于:

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.

机器默认权限设置不授予使用CLSID {148bee7f -6123- 41ee - 8cca - e3902bd0d0d8}的COM服务器应用程序的本地激活权限给用户somemchine \SomeUser SID (s - 1-5-21-48838816870 - 216442 -1987552629-1003)可以使用组件服务管理工具修改此安全权限。

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.

如果是这样,DCOMCNFG运行。EXE,组件服务,电脑,我的电脑(或其他名称),DCOM配置(你可以回答“不”如果它要求如果你想解决什么),如果应用程序事件日志消息,然后找到它的名字在事件日志消息,通过物品的名称,如果CLSID的事件日志消息(就像上面的例子),那么找到它的CLSID“{ 148 b…}“(那只是我粘贴进来的一个随机CLSID——它可能会匹配你的000209FF……”选择更多的动作……属性,到Security选项卡。

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.

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

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

这只是一个猜测,但您可以尝试一下,或者类似的东西(例如,通过DCOMCNFG授予对CLSID的访问权)。

#4


4  

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:

我很难用公认的答案解决这个问题,因为Microsoft Word 97 - 2003的文档记录没有列在DCOM配置项中。我在Technet的博客中找到了解决方案,他们正确地解释了这个问题:

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.

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

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.

从Windows XP到Windows Server 2008的x64操作系统,DCOMCNFG的64位版本。EXE不能正确配置用于远程激活的32位DCOM应用程序。这种行为导致原本要远程激活的组件被本地激活。这种行为不会发生在Windows 7和Windows Server 2008 R2以及更高版本中。

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

裁判: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:

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

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.

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

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

关于这个主题的进一步信息,你也可以阅读这篇文章。

#5


1  

If you cannot find Microsoft Word Application in DCOM

如果在DCOM中找不到微软的Word应用程序

On 64 bit system with 32 bit Office try this:

在64位系统上有32位的办公室试试这个:

  1. List item
  2. 列表项
  3. Start
  4. 开始
  5. Run
  6. 运行
  7. mmc-32
  8. mmc-32
  9. File
  10. 文件
  11. Add Remove Snap-in
  12. 添加删除管理单元
  13. Component Services
  14. 组件服务
  15. Add
  16. 添加
  17. OK
  18. 好吧
  19. Console Root
  20. 控制台根
  21. Component Services
  22. 组件服务
  23. Computers
  24. 电脑
  25. My Computer
  26. 我的电脑
  27. DCOM Config
  28. DCOM配置

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. 查找“Microsoft Word 97 - 2003文档”(如果缺少该文档,请检查您的Word是否也是64位的(如果是Windows)
  3. Right click -> Properties
  4. 点击右键- >属性
  5. Go To Tab Security and Edit the "Customize" radio buttons so that IIS_IUSRS could have rights for launch and access
  6. 转到Tab Security并编辑“自定义”单选按钮,以便IIS_IUSRS可以有启动和访问的权限
  7. Go to Tab Identity and choose "The interactive user" Apply changes and try again
  8. 转到Tab Identity并选择“交互式用户”应用更改并再次尝试
  9. If all this fails, go also to tab "General" and in "Authentication Level" drop down choose "None".
  10. 如果这一切都失败了,也转到tab“General”,在“身份验证级别”下拉菜单中选择“None”。

#1


28  

This worked for me:

这工作对我来说:

  1. In the command line put DCOMCNFG
  2. 在命令行中放置DCOMCNFG
  3. Component Services -> Computers -> My Computer -> DCOM Config
  4. 组件服务->计算机->我的计算机-> DCOM配置
  5. 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)
  6. 查找“Microsoft Word 97 - 2003文档”(如果缺少,请检查您的Word是否也是64位(如果您的Windows是),如果它没有运行mmc comexp。msc /32代替DCOMCNFG在步骤1中(暗黑这里建议)
  7. Right click -> Properties
  8. 点击右键- >属性
  9. Go To Tab Security and Edit the "Customize" radio buttons so that IIS_IUSRS could have rights for launch and access
  10. 转到Tab Security并编辑“自定义”单选按钮,以便IIS_IUSRS可以有启动和访问的权限
  11. Go to Tab Identity and choose "The interactive user"
  12. 进入标签标识,选择“交互用户”
  13. Apply changes and try again
  14. 应用更改并再次尝试
  15. If all this fails, go also to tab "General" and in "Authentication Level" drop down choose "None".
  16. 如果这一切都失败了,也转到tab“General”,在“身份验证级别”下拉菜单中选择“None”。

#2


58  

Ok, I resolved this problem with this steps:

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

  1. In the command line put DCOMCNFG
  2. 在命令行中放置DCOMCNFG
  3. Expand Console Root > Component Service > Computers, right-click on My Computer, And Select Properties
  4. 扩展控制台根>组件服务>计算机,右键单击我的计算机,并选择Properties。
  5. In the Tab COM Security > Launch and Activation Permissions Click in Edit Default
  6. 在选项卡COM安全>启动和激活权限中,单击“编辑默认”
  7. Add the User (Ex. IIS_IUSRS) or service
  8. 添加用户(例如IIS_IUSRS)或服务
  9. Check Allow Local Launch and Local Activation
  10. 检查允许本地启动和本地激活。

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

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

#3


11  

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:

查看事件查看器,在Windows日志、系统、安装Word的服务器机器上。您是否看到一个事件被记录下来,其内容类似于:

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.

机器默认权限设置不授予使用CLSID {148bee7f -6123- 41ee - 8cca - e3902bd0d0d8}的COM服务器应用程序的本地激活权限给用户somemchine \SomeUser SID (s - 1-5-21-48838816870 - 216442 -1987552629-1003)可以使用组件服务管理工具修改此安全权限。

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.

如果是这样,DCOMCNFG运行。EXE,组件服务,电脑,我的电脑(或其他名称),DCOM配置(你可以回答“不”如果它要求如果你想解决什么),如果应用程序事件日志消息,然后找到它的名字在事件日志消息,通过物品的名称,如果CLSID的事件日志消息(就像上面的例子),那么找到它的CLSID“{ 148 b…}“(那只是我粘贴进来的一个随机CLSID——它可能会匹配你的000209FF……”选择更多的动作……属性,到Security选项卡。

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.

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

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

这只是一个猜测,但您可以尝试一下,或者类似的东西(例如,通过DCOMCNFG授予对CLSID的访问权)。

#4


4  

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:

我很难用公认的答案解决这个问题,因为Microsoft Word 97 - 2003的文档记录没有列在DCOM配置项中。我在Technet的博客中找到了解决方案,他们正确地解释了这个问题:

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.

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

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.

从Windows XP到Windows Server 2008的x64操作系统,DCOMCNFG的64位版本。EXE不能正确配置用于远程激活的32位DCOM应用程序。这种行为导致原本要远程激活的组件被本地激活。这种行为不会发生在Windows 7和Windows Server 2008 R2以及更高版本中。

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

裁判: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:

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

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.

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

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

关于这个主题的进一步信息,你也可以阅读这篇文章。

#5


1  

If you cannot find Microsoft Word Application in DCOM

如果在DCOM中找不到微软的Word应用程序

On 64 bit system with 32 bit Office try this:

在64位系统上有32位的办公室试试这个:

  1. List item
  2. 列表项
  3. Start
  4. 开始
  5. Run
  6. 运行
  7. mmc-32
  8. mmc-32
  9. File
  10. 文件
  11. Add Remove Snap-in
  12. 添加删除管理单元
  13. Component Services
  14. 组件服务
  15. Add
  16. 添加
  17. OK
  18. 好吧
  19. Console Root
  20. 控制台根
  21. Component Services
  22. 组件服务
  23. Computers
  24. 电脑
  25. My Computer
  26. 我的电脑
  27. DCOM Config
  28. DCOM配置

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. 查找“Microsoft Word 97 - 2003文档”(如果缺少该文档,请检查您的Word是否也是64位的(如果是Windows)
  3. Right click -> Properties
  4. 点击右键- >属性
  5. Go To Tab Security and Edit the "Customize" radio buttons so that IIS_IUSRS could have rights for launch and access
  6. 转到Tab Security并编辑“自定义”单选按钮,以便IIS_IUSRS可以有启动和访问的权限
  7. Go to Tab Identity and choose "The interactive user" Apply changes and try again
  8. 转到Tab Identity并选择“交互式用户”应用更改并再次尝试
  9. If all this fails, go also to tab "General" and in "Authentication Level" drop down choose "None".
  10. 如果这一切都失败了,也转到tab“General”,在“身份验证级别”下拉菜单中选择“None”。