无法找到ArgumentException的根本原因

时间:2019-05-01 09:20:02

标签: c# .net windbg sos

我正在调查应用程序中大量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] 

如何找出此异常的来源?看起来好像是堆栈跟踪中缺少的部分。

1 个答案:

答案 0 :(得分:2)

根据Microsoft文档,如果满足以下任一条件,则PropertyInfo.GetValue()方法将引发ArgumentException

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

-或-

找不到属性的get访问器。”

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