从HRESULT异常:0x800A03EC错误 [英] Exception from HRESULT: 0x800A03EC Error

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

问题描述

我收到HRESULT:0x800A03EC运行Excel插件具有以下code时错误:

  Excel.Range RNG = ActiveSheet.Cells [X,Y]为Excel.Range;
之前= rng.Value2串;
字符串cleanV = System.Text.RegularEx pressions.Regex.Replace(前,@\\ S +,);
rng.set_Value(cleanV);

当错误发生的X和Y被设置为1,从而Excel范围不受侵犯。
我广泛搜索并尝试了一些设置单元格值的方式(如细胞[X,Y],range.set_Value()),但我在亏损,为什么这个错误发生,如何避免它。

任何帮助是极大AP preciated。

下面是异常详细信息:


  System.Runtime.InteropServices.COMException是由用户code未处理
  的HResult = -2146827284
  消息=从HRESULT异常:0x800A03EC
  来源=
  错误code = -2146827284
  堆栈跟踪:
       在System.RuntimeType.ForwardCallToInvokeMember(字符串memberName,标志的BindingFlags,对象目标的Int32 [] aWrapperTypes,MessageData&安培; MSGDATA)
       在Microsoft.Office.Interop.Excel.Range.set_Value(对象RangeValueDataType,对象的值)
       在用C ImportValidation.ThisAddIn.removeAnySpaces(的Int32 X,的Int32 Y):\\用户\\ dshevelev \\文档\\ Visual Studio 2012中\\项目\\ ImportValidation \\ ImportValidation \\ ThisAddIn.cs:354线
       在ImportValidation.ThisAddIn.ReadHeaders(哈希表columnAddress)在C:\\用户\\ dshevelev \\文档\\ Visual Studio 2012中\\项目\\ ImportValidation \\ ImportValidation \\ ThisAddIn.cs:123线
       在用C ImportValidation.ThisAddIn.mapColumns():\\用户\\ dshevelev \\文档\\ Visual Studio 2012中\\项目\\ ImportValidation \\ ImportValidation \\ ThisAddIn.cs:493线
       在ImportValidation.Ribbon1.button6_Click(对象发件人,RibbonControlEventArgs E)在C:\\用户\\ dshevelev \\文档\\ Visual Studio 2012中\\项目\\ ImportValidation \\ ImportValidation \\ Ribbon1.cs:55行
       在Microsoft.Office.Tools.Ribbon.RibbonPropertyStorage.ControlActionRaise(IRibbonControl控制)
       在Microsoft.Office.Tools.Ribbon.RibbonPropertyStorage.ButtonClickCallback(RibbonComponentImpl组件,对象[]参数)
       在Microsoft.Office.Tools.Ribbon.RibbonManagerImpl.Invoke(RibbonComponentCallback回调,对象[]参数)
       在Microsoft.Office.Tools.Ribbon.RibbonMethodInfo.Invoke(obj对象,的BindingFlags invokeAttr,粘结剂粘合,对象[]参数,CultureInfo的文化)
       在Microsoft.Office.Tools.Ribbon.RibbonManagerImpl.System.Reflection.IReflect.InvokeMember(字符串名称,的BindingFlags invokeAttr,活页夹粘结剂,目标对象,对象[] ARGS,ParameterModifier []修饰符,CultureInfo的文化的String [] namedParameters)
  的InnerException:


解决方案

得到了同样的错误,在此行

 对象TEMP = range.Cells [I] [0] .value的;

基于非零指数解决

 对象TEMP = range.Cells [I] [1] .value的;

这怎么可能是谁创造了​​这个库中的人还以为是使用非从零开始的索引是一个好主意?

I am getting "HRESULT: 0x800A03EC" error when running Excel add-in with following code:

Excel.Range rng = ActiveSheet.Cells[x, y] as Excel.Range;                
string before = rng.Value2; 
string cleanV = System.Text.RegularExpressions.Regex.Replace(before, @"\s+", "");
rng.set_Value(cleanV);

When error happens X and Y are set to 1, thus Excel range is not violated. I searched extensively and tried a number of ways of setting the cell value (eg. Cells[x,y], range.set_Value()) but am at loss why this error happens and how to avoid it.

Any help is greatly appreciated.

Below are exception details:


System.Runtime.InteropServices.COMException was unhandled by user code
  HResult=-2146827284
  Message=Exception from HRESULT: 0x800A03EC
  Source=""
  ErrorCode=-2146827284
  StackTrace:
       at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
       at Microsoft.Office.Interop.Excel.Range.set_Value(Object RangeValueDataType, Object value)
       at ImportValidation.ThisAddIn.removeAnySpaces(Int32 x, Int32 y) in c:\Users\dshevelev\Documents\Visual Studio 2012\Projects\ImportValidation\ImportValidation\ThisAddIn.cs:line 354
       at ImportValidation.ThisAddIn.ReadHeaders(Hashtable columnAddress) in c:\Users\dshevelev\Documents\Visual Studio 2012\Projects\ImportValidation\ImportValidation\ThisAddIn.cs:line 123
       at ImportValidation.ThisAddIn.mapColumns() in c:\Users\dshevelev\Documents\Visual Studio 2012\Projects\ImportValidation\ImportValidation\ThisAddIn.cs:line 493
       at ImportValidation.Ribbon1.button6_Click(Object sender, RibbonControlEventArgs e) in c:\Users\dshevelev\Documents\Visual Studio 2012\Projects\ImportValidation\ImportValidation\Ribbon1.cs:line 55
       at Microsoft.Office.Tools.Ribbon.RibbonPropertyStorage.ControlActionRaise(IRibbonControl control)
       at Microsoft.Office.Tools.Ribbon.RibbonPropertyStorage.ButtonClickCallback(RibbonComponentImpl component, Object[] args)
       at Microsoft.Office.Tools.Ribbon.RibbonManagerImpl.Invoke(RibbonComponentCallback callback, Object[] args)
       at Microsoft.Office.Tools.Ribbon.RibbonMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at Microsoft.Office.Tools.Ribbon.RibbonManagerImpl.System.Reflection.IReflect.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters)
  InnerException: 

解决方案

Got same error in this line

 Object temp = range.Cells[i][0].Value;

Solved with non-zero based index

 Object temp = range.Cells[i][1].Value;

How is it possible that the guys who created this library thought it was a good idea to use non-zero based indexing?

这篇关于从HRESULT异常:0x800A03EC错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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