我正在尝试使用 YAXLib 处理 XML,但是每当我尝试使用 int、double 或 float 字段序列化类时,都会崩溃。YAXLib 尝试调用
DefaultValue = MemberType.InvokeMember(string.Empty, BindingFlags.CreateInstance, null, null, new object[0]);
MemberType
对象在哪里System.Int32
Type
。
当然 Int32 没有要调用的构造函数。我试图了解这首先是如何工作的。这是在新版本的 mono/C# 中引入的东西吗?
这是在 Unity3d 中,带有 Mono,.NET 2.0.5
MissingMethodException: Constructor on type 'System.Int32' not found.
System.MonoType.InvokeMember (System.String name, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object target, System.Object[] args, System.Reflection.ParameterModifier[] modifiers, System.Globalization.CultureInfo culture, System.String[] namedParameters) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/MonoType.cs:398)
System.Type.InvokeMember (System.String name, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object target, System.Object[] args) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/Type.cs:1149)
YAXLib.MemberWrapper.InitDefaultValue () (at Assets/Vendor/YAXLib/MemberWrapper.cs:691)
YAXLib.MemberWrapper.InitInstance () (at Assets/Vendor/YAXLib/MemberWrapper.cs:682)
YAXLib.MemberWrapper..ctor (System.Reflection.MemberInfo memberInfo, YAXLib.YAXSerializer callerSerializer) (at Assets/Vendor/YAXLib/MemberWrapper.cs:122)
YAXLib.YAXSerializer+<GetFieldsToBeSerialized>c__Iterator1.MoveNext () (at Assets/Vendor/YAXLib/YAXSerializer.cs:2815)
YAXLib.YAXSerializer.SerializeBase (System.Object obj, System.Xml.Linq.XName className) (at Assets/Vendor/YAXLib/YAXSerializer.cs:722)
YAXLib.YAXSerializer.SerializeBase (System.Object obj) (at Assets/Vendor/YAXLib/YAXSerializer.cs:609)
YAXLib.YAXSerializer.SerializeXDocument (System.Object obj) (at Assets/Vendor/YAXLib/YAXSerializer.cs:539)
YAXLib.YAXSerializer.Serialize (System.Object obj) (at Assets/Vendor/YAXLib/YAXSerializer.cs:349)
DataHandler..ctor () (at Assets/DataWrangling/DataHandler.cs:36)
YAXTestHarness.Start () (at Assets/DataWrangling/YAXTestHarness.cs:8)