简体   繁体   English

远程过程调用失败 IIS 内的 Excel

[英]The remote procedure call failed Excel inside IIS

When I try to download an Excel file using asp.net I get this Error当我尝试使用 asp.net 下载 Excel 文件时,出现此错误

The remote procedure call failed.远程过程调用失败。 (Exception from HRESULT: 0x800706BE) Description: An unhandled exception occurred during the execution of the current web request. (来自 HRESULT 的异常:0x800706BE) 描述:在执行当前 Web 请求期间发生未处理的异常。 Please review the stack trace for more information about the error and where it originated in the code.请查看堆栈跟踪以获取有关错误及其在代码中的来源的更多信息。

Exception Details: System.Runtime.InteropServices.COMException: The remote procedure call failed.异常详细信息:System.Runtime.InteropServices.COMException:远程过程调用失败。 (Exception from HRESULT: 0x800706BE) (来自 HRESULT 的异常:0x800706BE)

Source Error:源错误:

 xlworkbook.SaveAs(Path) xlworkbook.Close() xlAPP.Quit() 'error on this line

[COMException (0x800706be): The remote procedure call failed. [COMException (0x800706be): 远程过程调用失败。 (Exception from HRESULT: 0x800706BE)] (来自 HRESULT 的异常:0x800706BE)]
Microsoft.Office.Interop.Excel.ApplicationClass.Quit() +0 Microsoft.Office.Interop.Excel.ApplicationClass.Quit() +0

and sometimes the error is有时错误是

The remote procedure call failed.远程过程调用失败。 (Exception from HRESULT: 0x800706BE) Description: An unhandled exception occurred during the execution of the current web request. (来自 HRESULT 的异常:0x800706BE) 描述:在执行当前 Web 请求期间发生未处理的异常。 Please review the stack trace for more information about the error and where it originated in the code.请查看堆栈跟踪以获取有关错误及其在代码中的来源的更多信息。

Exception Details: System.Runtime.InteropServices.COMException: The remote procedure call failed.异常详细信息:System.Runtime.InteropServices.COMException:远程过程调用失败。 (Exception from HRESULT: 0x800706BE) (来自 HRESULT 的异常:0x800706BE)

Source Error:源错误:

 xlworkbook.SaveAs(Path) xlworkbook.Close() 'line triggering the error xlAPP.Quit()

[COMException (0x800706be): The remote procedure call failed. [COMException (0x800706be): 远程过程调用失败。 (Exception from HRESULT: 0x800706BE)] (来自 HRESULT 的异常:0x800706BE)]

 Microsoft.Office.Interop.Excel._Workbook.Close(Object SaveChanges, Object Filename, Object RouteWorkbook) +0

I DID ALL The Below Steps我做了以下所有步骤

  1. Open Windows Explorer打开 Windows 资源管理器

  2. Depending on whether you installed a 32bit or 64bit version of office you will need to do one (or both) of the following: 32bit Office installation: Navigate to C:\\Windows\\System32\\config\\systemprofile 64bit Office installation:根据您安装的是 32 位还是 64 位版本的 Office,您需要执行以下一项(或两项)操作: 32 位 Office 安装:导航至 C:\\Windows\\System32\\config\\systemprofile 64 位 Office 安装:

  3. Navigate to C:\\Windows\\SysWOW64\\config\\systemprofile导航到 C:\\Windows\\SysWOW64\\config\\systemprofile

  4. Verify the folder "Desktop" exists (create it if it's not there)验证文件夹“桌面”是否存在(如果不存在则创建它)

  5. Right click > Properties右键单击 > 属性

  6. 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)在安全选项卡上:添加具有默认权限(读取和执行;列出文件夹内容;读取)的站点运行帐户(例如:网络服务)

In the dcomconfig utility,在 dcomconfig 实用程序中,

go to Component Services --> Computers --> My Computer --> DCom Config --> Microsoft Excel Application (and Powerpoint)转到组件服务 --> 计算机 --> 我的电脑 --> DCom 配置 --> Microsoft Excel 应用程序(和 Powerpoint)

Right click it and go to properties.右键单击它并转到属性。 Go to security tab.转到安全选项卡。 Under Security在安全之下

1, Launch & Activation Permissions --> Choose customise and click Edit. 1、Launch & Activation Permissions --> 选择自定义并点击编辑。 Add User Network Service and check everything under Allow for it.添加用户网络服务并检查允许下的所有内容。

  1. Do the same for Access Permissions and Configuration Permissions.对访问权限和配置权限执行相同操作。

Then click Apply and close everything.然后单击应用并关闭所有内容。

Sometimes I can download the file but sometimes I got this error Any ideas why?有时我可以下载文件,但有时我会收到此错误任何想法为什么?

I did method 4 and it worked for me: https://support.microsoft.com/en-gb/kb/2758592我做了方法 4,它对我有用https : //support.microsoft.com/en-gb/kb/2758592

Method 4: Investigate possible issues with COM add-ins方法 4:调查 COM 加载项可能存在的问题

Many developers create add-ins for Excel.许多开发人员为 Excel 创建加载项。 These add-ins are divided into two types: Excel add-ins that are saved as .xla, .xlam, or .xll files.这些加载项分为两种类型:另存为 .xla、.xlam 或 .xll 文件的 Excel 加载项。 COM add-ins. COM 加载项。 These add-ins usually have to be installed and include DLLs and registry keys.通常必须安装这些加载项并包括 DLL 和注册表项。 COM add-ins created for one version of Excel frequently are not compatible with a newer version, and may cause crashes.为一个 Excel 版本创建的 COM 加载项经常与较新版本不兼容,并可能导致崩溃。 They are not disabled by Safe mode, and should be investigated separately.它们不会被安全模式禁用,应单独调查。

To disable COM add-ins, follow these steps: Select File > Options > Add-ins.要禁用 COM 加载项,请执行以下步骤: 选择文件 > 选项 > 加载项。 At the bottom of the dialog box, change the Manage dropdown to COM add-ins, and select Go.在对话框底部,将管理下拉列表更改为 COM 加载项,然后选择执行。 Clear the checkbox for any enabled COM add-ins.清除任何已启用的 COM 加载项的复选框。 select OK.选择确定。 If disabling the COM add-ins alleviates the issue, try enabling them one at a time to test for the problem add-in.If these steps do not resolve your issue, continue to method 5.如果禁用 COM 加载项可以缓解问题,请尝试一次启用它们以测试有问题的加载项。如果这些步骤不能解决您的问题,请继续执行方法 5。

I did all these five steps and finally selected Interactive user in Identity Tab.我完成了所有这五个步骤,最后在 Identity Tab 中选择了 Interactive user。 its worked!!它的工作!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM