【问题标题】:Unable to find root cause of ArgumentException无法找到 ArgumentException 的根本原因
【发布时间】:2019-09-19 21:22:19
【问题描述】:

我正在调查应用程序中大量 ArgumentException 的原因(我怀疑其主要原因是内存碎片/内存不足异常)。 问题是我找不到这个异常来自哪里。

我有问题服务的内存转储,但我只能看到它发生在其中一个线程上并且它与反射有关,除了我似乎找不到异常的原因.

ArgumentException 详细信息:

Exception type:   System.ArgumentException
Message:          Missing parameter does not have a default value.
InnerException:   <none>
StackTrace (generated):
    SP       IP       Function
    0347D2F0 72B006F2 mscorlib_ni!System.Reflection.MethodBase.CheckArguments(System.Object[], System.Reflection.Binder, System.Reflection.BindingFlags, System.Globalization.CultureInfo, System.Signature)+0xc27c02
    0347D328 71EC0EDB mscorlib_ni!System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)+0x9b
    0347D35C 71EC0DD7 mscorlib_ni!System.Reflection.RuntimeMethodInfo.Invoke(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)+0x37
    0347D390 71EC0D8E mscorlib_ni!System.Reflection.RuntimePropertyInfo.GetValue(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)+0x3e

StackTraceString: <none>
HResult: 80070057

~#s; !clrstack 的输出:

OS Thread Id: 0x524 (1)
Child SP       IP Call Site
033fcf00 7726a8fc [HelperMethodFrame: 033fcf00] 
033fcfb0 72b006f2 System.Reflection.MethodBase.CheckArguments(System.Object[], System.Reflection.Binder, System.Reflection.BindingFlags, System.Globalization.CultureInfo, System.Signature)
033fcfe8 71ec0edb System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)
033fd01c 71ec0dd7 System.Reflection.RuntimeMethodInfo.Invoke(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)
033fd050 71ec0d8e System.Reflection.RuntimePropertyInfo.GetValue(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)
033fda64 730eebe6 [DebuggerU2MCatchHandlerFrame: 033fda64] 
033fda34 730eebe6 [GCFrame: 033fda34] 
033fda18 730eebe6 [GCFrame: 033fda18] 

如何找出这个异常来自哪里?它看起来像是堆栈跟踪中缺少的部分。

【问题讨论】:

  • 你需要调试一下。
  • @spodger 这发生在我们的生产服务器上,我们在本地机器上的测试环境中看不到这些。
  • ~#s; !clrstack 呢?
  • 更新问题

标签: c# .net windbg sos


【解决方案1】:

根据 Microsoft 文档,当以下任一情况为真时,PropertyInfo.GetValue() 方法会抛出 ArgumentException

"索引数组不包含所需的参数类型。

-或-

未找到该属性的 get 访问器。"

我会在源代码中查找任何调用GetValue() 的调用,并检查传递给它们的参数。上述两种情况之一可能是罪魁祸首。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-09-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-02-20
  • 1970-01-01
相关资源
最近更新 更多