IIS7 中调用Office Interop 问题汇总 (转)

I’ve just started working on a new project for which we had to dig out one of our older libraries. We wrote it to retrieve data from MS Excel workbooks using the Office interop assemblies, and thus far it has never given us issues. A slight change this time round was that we were using our library in an ASP.NET site rather than a desktop application. As a result I was faced with two errors that we’d never seen before.

Error Message:

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

Solution:

This is a COM permissions problem.

  1. Start > Run > dcomcnfg (or “mmc -32″ and then add the Component Services snap-in manually if you can’t find the app under step 3) (Or MMC comexp.msc /32)
  2. Navigate to Component Services > Computers > My Computer > DCOM Config
  3. Locate the MS application giving you trouble (eg: “Microsoft Excel Application” for Excel or “Microsoft Word 97 – 2003 Document” for Word)
  4. Right click > Properties
  5. On the security tab: Select Customize under Launch and Activation Permissions and click Edit…
  6. Add the account under which the site is running (eg: IIS_USER, Network Service) and assign Local Launch & Local Activation permissions
  7. Voila!
Error Message:

[COMException (0x800a03ec): Microsoft Excel cannot access the file '<filename>'. There are several possible reasons:
• The file name or path does not exist.
• The file is being used by another program.
• The workbook you are trying to save has the same name as a currently open workbook.

Solution:

This seems to be an issue with Excel/Word/etc not having access to a profile when being started via the interop route.

    1. Open Windows Explorer
    2. Depending on whether you installed a 32bit or 64bit version of office you will need to do one  (or both) of the following:
      1. 32bit Office installation: Navigate to C:\Windows\System32\config\systemprofile
      2. 64bit Office installation: Navigate to C:\Windows\SysWOW64\config\systemprofile
    3. Verify the folder "Desktop" exists (create it if it's not there)
    4. Right click > Properties
    5. On the security tab: Add the account under which the site is running (eg: Network Service) with default permissions (Read & execute; List folder contents; Read) (这一步很关键)
    6. Voila!

转载于:https://www.cnblogs.com/muskteer/archive/2013/01/28/2879935.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值