且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Windows 7 .net Excel .SaveAs()来自HRESULT的错误异常:0x800A03EC

更新时间:2022-06-26 01:06:10

注意:这需要简化一下,因为它是我在我们所做的所有修复程序的汇编内部维基,但我不知道什么变化的一部分使它工作,所以我将包括所有。

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.

-Run 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.

- 尝试 ApplicationPoolIdentity更改。

-Try the below DCOMCNFG & ApplicationPoolIdentity change.

- 以管理员身份登录命令提示符。

- 导航到c:\Windows\System32\inetsrv>并运行'appcmd set config -section:asp -enableParentPaths:true'

-Run command prompt as Administrator.
-Navigate to c:\Windows\System32\inetsrv> 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:

DCOMCNFG For windows 7:

错误发生在'Excel应用程序=新应用程序();'调用

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'.