Windows 7 .net Excel .SaveAs() 来自 HRESULT 的错误异常:0x800A03EC [英] Windows 7 .net Excel .SaveAs() Error Exception from HRESULT: 0x800A03EC

查看:49
本文介绍了Windows 7 .net Excel .SaveAs() 来自 HRESULT 的错误异常:0x800A03EC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:
我在工作中烤了我的旧硬盘,然后又买了一个新硬盘.有了这个,我将不得不重建我的机器.我的经理在他的借用笔记本电脑上安装了 Windows 7,而我的机器出现故障时我一直在使用该笔记本电脑.但是我遇到了一个问题.

Background:
I toasted my old hard drive at work and am getting a new one. With that I'll have to rebuild my machine. My manager has Windows 7 installed on him loaner laptop that I've been using while my machine is out of commision. But I've run into a problem.

我们有大量使用 Microsoft.Office.Interop.Excel 参考的应用程序.到目前为止,我已经解决了一些错误,但最近几天我一直坚持的错误(我的机器在第一次重建后实际上遭受了硬盘驱动器故障)并且无法找到修复程序.我已搜索过此错误,但在 Windows 7 上找不到任何遇到此问题的人,尽管我尝试了其他针对 Windows Server 2008 的修复程序均无济于事.

We have a fair number of apps that make use of the Microsoft.Office.Interop.Excel reference. I've gotten past a few errors so far but the one I've been stuck on for the last few days (my machine actually suffered the hard drive failure after the first rebuild) and have been unnable to find a fix. I have searched for this error but can't find anyone having this problem on Windows 7, although I have tried other fixes for Windows Server 2008 to no avail.

如果我不能解决这个问题,我将无法使用 Windows 7,并且想知道在我重建机器之前只需要擦除它并重新启动(第三次).

If I can't fix this problem, I will not be able to use Windows 7 and would like to know that before I rebuild a machine only to have to wipe it and start again (for the third time).

问题:
操作系统:Windows 7 企业版
错误消息:HRESULT 异常:0x800A03EC
代码:

Problem:
OS: Windows 7 Enterprise
Error Message: Exception from HRESULT: 0x800A03EC
Code:

Private m_xls As Microsoft.Office.Interop.Excel.Application
Private m_wkbk As Microsoft.Office.Interop.Excel.Workbook
Private m_wksht As Microsoft.Office.Interop.Excel.Worksheet
m_xls = New Application
m_xls.Visible = False : m_xls.DisplayAlerts = False
m_wkbk = m_xls.Workbooks.Open(Me.FilePath)
m_wksht = CType(m_wkbk.ActiveSheet, Worksheet)
'...Write some data...'
m_wkbk.SaveAs(Me.FilePath, XlFileFormat.xlWorkbookNormal, Missing.Value, Missing.Value, False, False, XlSaveAsAccessMode.xlNoChange, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value)

错误出现在最后一行.

到目前为止我已经尝试过:

What I've tried so far:

  1. 更改 AppPool 以使用NetworkService 帐户(它是'ApplicationPoolIdentity' 我在用户列表中找不到安全设定).然后给NetworkService 帐户完全访问权限到相应的文件夹.
  2. 授予 NetworkService 访问 DCOMCNFG 中所有Microsoft Excel 应用程序"设置的权限
  3. 运行此命令appcmd set config -section:asp -enableParentPaths:true",因为这是我唯一能找到的其他东西
  4. 使用有效但导致不同错误的 .SaveCopyAs()

我只是想看看其他人是否遇到过这个问题,因为 Windows 7 是新的.我可以使用 Server 2008,但我想在告诉我的经理它行不通之前有一些可靠的理由.

I just wanted to see if anyone else has run into this or not since Windows 7 is new. I can go with Server 2008 but I would like to have some solid reasoning behind it before I tell my manager it won't work.

谢谢你,杰夫

推荐答案

注意:这需要稍微精简一下,因为它是我在内部 wiki 上所做的所有修复的汇编,但我不确定是什么更改的子集使它起作用,因此我将其全部包含在内.

Note: This needs to be condensed a bit as it's a compilation of all the fixes I've been making on our internal wiki but I'm not sure what subset of changes made it work so I'll include it all.

解决方案:

以下更改可能是如何解决此问题的超集.

The following changes may be a superset of how to address this problem.

-运行 DCOMCNFG.exe 并导航到组件服务>计算机>我的电脑".
-右键单击我的电脑",然后单击属性".
- 打开COM 安全"选项卡.为列出的每个按钮添加您的帐户(访问权限"和启动和激活权限"下的编辑限制..."和编辑默认值..."按钮).为您的帐户提供所有访问选项.点击应用",然后点击确定".
- 当仍在 DCOMCNFG 中时,展开我的电脑"链接并打开DCOM 配置"文件夹.
- 右键单击​​Microsoft Excel 应用程序"并选择属性".
- 在安全"选项卡下,为启动和激活权限"和配置权限"选择自定义"选项.两者都单击编辑..."按钮.让您的帐户访问所有内容.
- 当仍在Microsoft Excel 应用程序"的属性"中时,转到身份"选项卡.
- 选择交互式用户"选项.
- 单击应用",然后单击确定".
-重新启动您的计算机.

-Run DCOMCNFG.exe and navigate to 'Component Services>Computers>My Computer'.
-Right click 'My Computer' and click 'Properties'.
-Open the 'COM Security' tab. Add your account for everyone of the buttons listed ('Edit Limits...' and 'Edit Default...' buttons under 'Access Permission' & 'Launch and Activate Permissions'). Give your account all access options. Click 'Apply' then 'OK'.
-While still in DCOMCNFG expand the 'My Computer' link and open the 'DCOM Config' folder.
-Right click on 'Microsoft Excel Application' and select 'Properties'.
-Under the 'Security' tab choose the 'Customize' option for 'Launch and Activation Permissions' and 'Configuration Permissions'. For both click the 'Edit...' button. Give your account access to everything.
-While still in the 'Properties' for 'Microsoft Excel Application' go to the 'Identity' tab.
-Select the 'The Interactive User' option.
-Click 'Apply' then 'OK'.
-Restart your computer.

-试试下面的 DCOMCNFG &ApplicationPoolIdentity 更改.

-Try the below DCOMCNFG & ApplicationPoolIdentity change.

-以管理员身份运行命令提示符.
-导航到 c:WindowsSystem32inetsrv> 并运行 'appcmd set config -section:asp -enableParentPaths:true'

-Run command prompt as Administrator.
-Navigate to c:WindowsSystem32inetsrv> and run 'appcmd set config -section:asp -enableParentPaths:true'

您也可以使用 .SaveCopyAs() ,尽管这可能仍然无法解决问题并且需要更改代码.

Alternately you could use .SaveCopyAs() although this may still not address the problem and will require code changes.

DCOMCNFG 对于 Windows 7:

此错误发生在Excel app = New Application();"上来电

This error happens on 'Excel app = New Application();' calls

此链接详细说明了如何解决 XP/Server 2003 的问题,但可以适应 Windows 7:http://blog.crowe.co.nz/archive/2006/03/02/589.aspx

This link details how to fix the problem for XP/Server 2003 but can be adapted to Windows 7: http://blog.crowe.co.nz/archive/2006/03/02/589.aspx

我没有/找不到ASPNET"帐户.您必须检查应用程序池以了解应用程序的运行方式.
为此,请进入计算机管理>服务和应用程序>Internet 信息服务>应用程序池"
右键单击相应的 AppPool 并选择高级设置".在流程模型>身份"下,您可以找到它正在运行的帐户.我的是ApplicationPoolIdentity",我也找不到,所以我将其更改为网络服务",如 Windows Server 2003.
一旦设置好运行 DCOMCNFG.exe.导航到组件服务>计算机>我的电脑>DCOM 配置".
找到并右键单击Microsoft Excel 应用程序"并选择属性".选择安全"选项卡.在启动和激活权限"下选择自定义"并单击编辑".
然后单击添加..."按钮.
键入相应帐户的名称,在本例中为网络服务",然后单击检查名称".然后点击确定".
返回启动和激活权限"页面,突出显示网络服务"帐户并选中本地启动"和本地激活"复选框.然后点击确定".

I do not have/could not find an 'ASPNET' account. You have to check the application pool to find out what the app is running as.
To do that go into 'Computer Management>Services and Applications>Internet Information Services>Application Pools'
Right click on the appropriate AppPool and choose 'Advanced Settings'. Under 'Process Model>Identity' you can find the account it is running under. Mine was 'ApplicationPoolIdentity' which I also couldn't find so I changed it to 'Network Service' like Windows Server 2003.
Once this is set run DCOMCNFG.exe. Navigate to 'Component Services>Computers>My Computer>DCOM Config'.
Find and right-click on 'Microsoft Excel Application' and select 'Properties'. Choose the 'Security' tab. Under 'Launch and Activation Permissions' choose 'Customize' and click 'Edit'.
Then click the 'Add...' button.
Type the name of the the appropriate account, in this case 'Network Service' and click 'Check Names'. Then click 'OK'.
Back on the 'Launch and Activation Permissions' page highlight the 'Network Service' account and check the 'Local Launch' and 'Local Activation' check boxes. Then click 'OK'.

这篇关于Windows 7 .net Excel .SaveAs() 来自 HRESULT 的错误异常:0x800A03EC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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