我正在对表单调用 Tester.cs 中的函数进行单元测试,以下是错误:
Error 7/31/2012 10:43:11 PM One of the background threads threw exception:
System.TypeInitializationException: The type initializer for 'Tester.Tester' threw an exception. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: String
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at System.Int32.Parse(String s)
at Tester.Tester..cctor() in E:\Incubator\Tester\Tester\Tester.cs:line 35
--- End of inner exception stack trace ---
at Tester.Tester.Dispose(Boolean disposing)
at System.ComponentModel.Component.Finalize() MY-PC
第 35 行是一个代码,它基本上从配置文件中检索值并将其转换为整数:
private static int _part = int.Parse(ConfigurationManager.AppSettings["Part"]);
错误是什么?谢谢你。