简体   繁体   English

如何修复System.Runtime.InteropServices.COMException错误

[英]How to fix a System.Runtime.InteropServices.COMException error

I have created a C# WinForms project which calculates numerical values and writes them to an open Excel spreadsheet. 我创建了一个C#WinForms项目,该项目计算数值并将其写入打开的Excel电子表格。 The program works by allowing the user to open a spreadsheet in the Excel program. 该程序通过允许用户在Excel程序中打开电子表格来工作。 The writing is carried out by one method called private void updateExcel_Click(object sender, EventArgs e) which writes like so: 编写是通过一种称为private void updateExcel_Click(object sender, EventArgs e) ,其编写方式如下:

if (*in range*)
    MySheet.Cells[activeRow, activeColumn].Value = total;

This approach works like a charm, except when there is an unsubmitted change made in the. 这种方法的工作原理就像一种魅力,除非进行了未提交的更改。 By unsubmitted change I mean when the user goes directly into the spreadsheet and changes the number in the active cell without finalizing the change with one of: 未提交的更改是指用户直接进入电子表格并更改活动单元格中的数字而不用以下其中一项完成更改:

  • pressing enter 按Enter
  • pressing tab 按下标签
  • pressing an arrow key 按方向键
  • clicking elsewhere 点击其他地方

When I write to the affected cell once more with the program I get a System.Runtime.InteropServices.COMException error. 当我再次使用该程序写入受影响的单元格时,出现System.Runtime.InteropServices.COMException错误。 The full text being: 全文为:

Exception thrown: 'System.Runtime.InteropServices.COMException' in System.Dynamic.dll An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in System.Dynamic.dll Call was rejected by callee. 引发异常:System.Dynamic.dll中的“ System.Runtime.InteropServices.COMException” System.Dynamic.dll中发生了类型为“ System.Runtime.InteropServices.COMException”的未处理异常。被调用方拒绝了呼叫。 (Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED)) (来自HRESULT的异常:0x80010001(RPC_E_CALL_REJECTED))

Oddly enough, when the direct user change is finalized with one of the bulleted methods I get no error when I rewrite to the cell with the program. 奇怪的是,当直接用户更改使用项目符号方法之一完成时,使用程序重写到单元格时我没有出现任何错误。 How do I remedy my program to avoid the COMException error? 我该如何纠正我的程序以避免COMException错误?

I already tried following the msdn link: How to fix 'Call was rejected by callee' error . 我已经尝试过以下msdn链接: 如何修复“被呼叫者拒绝呼叫”错误 I called the C# method updateCell_Click from the space labeled "Insert your automation code here." 我从标记为“在此处插入自动化代码”的空间中调用了C#方法updateCell_Click。

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

相关问题 奇怪的System.Runtime.InteropServices.COMException错误 - Strange System.Runtime.InteropServices.COMException error 如何更正此错误的“ System.Runtime.InteropServices.COMException”? - How to correct this error of 'System.Runtime.InteropServices.COMException'? 如何避免System.Runtime.InteropServices.COMException? - How to avoid a System.Runtime.InteropServices.COMException? 'System.Runtime.InteropServices.COMException' - 'System.Runtime.InteropServices.COMException' System.Runtime.InteropServices.COMException - System.Runtime.InteropServices.COMException System.Runtime.InteropServices.COMException:未知错误(0x80005000) - System.Runtime.InteropServices.COMException: Unknown error (0x80005000) c#Windbg中的System.Runtime.InteropServices.COMException错误 - c# System.Runtime.InteropServices.COMException error in windbg 如何修复mscorlib.ni.dll中抛出的异常:“ System.Runtime.InteropServices.COMException”? - how to fix Exception thrown: 'System.Runtime.InteropServices.COMException' in mscorlib.ni.dll? 使用System.Runtime.InteropServices.COMException激活 - Activation with System.Runtime.InteropServices.COMException Windows应用程序中的System.Runtime.InteropServices.COMException - System.Runtime.InteropServices.COMException in Windows Application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM