ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

【Unity升级问题处理】Unity5.4.x升级到Unity2019遇到的坑-System.MissingMethodException

2022-03-02 12:03:52  阅读:165  来源: 互联网

标签:MissingMethodException name Unity5.4 成员 System 升级 BindingFlags 搜索 Reflection


原文链接:https://blog.csdn.net/u013294596/article/details/121565482

System.Reflection.BindingFlags
ReadSelectedTable Error = System.MissingMethodException: TABLE.xxx.rows Due to: Attempted to access a missing member.
at System.RuntimeType.InvokeMember (System.String name, System.Reflection.BindingFlags bindingFlags, System.Reflection.Binder binder, System.Object target, System.Object[] providedArgs, System.Reflection.ParameterModifier[] modifiers, System.Globalization.CultureInfo culture, System.String[] namedParams) [0x0070c] in <567df3e0919241ba98db88bec4c6696f>:0
at System.Type.InvokeMember (System.String name, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object target, System.Object[] args) [0x00000] in <567df3e0919241ba98db88bec4c6696f>:0
————————————————

官方解释:为了获取返回值,必须指定 BindingFlags.Instance 或 BindingFlags.Static。

指定 BindingFlags.Public 可在搜索中包含公共成员。

指定 BindingFlags.NonPublic 可在搜索中包含非公共成员(即私有成员和受保护的成员)。

指定 BindingFlags.FlattenHierarchy 可包含层次结构上的静态成员。

下列 BindingFlags 修饰符标志可用于更改搜索的执行方式:

BindingFlags.IgnoreCase,表示忽略 name 的大小写。

BindingFlags.DeclaredOnly,仅搜索 Type 上声明的成员,而不搜索被简单继承的成员。

可以使用下列 BindingFlags 调用标志表示要对成员采取的操作:

CreateInstance,表示调用构造函数。忽略 name。对其他调用标志无效。

InvokeMethod,表示调用方法,而不调用构造函数或类型初始值设定项。对 SetField 或 SetProperty 无效。

GetField,表示获取字段值。对 SetField 无效。

SetField,表示设置字段值。对 GetField 无效。

GetProperty,表示获取属性。对 SetProperty 无效。

SetProperty 表示设置属性。对 GetProperty 无效。

BindingFlags.Instance:对象实例
BindingFlags.Static:静态成员
BindingFlags.Public:指可在搜索中包含公共成员
BindingFlags.NonPublic:指可在搜索中包含非公共成员(即私有成员和受保护的成员)
BindingFlags.FlattenHierarchy:指可包含层次结构上的静态成员
BindingFlags.IgnoreCase:表示忽略 name 的大小写
BindingFlags.DeclaredOnly:仅搜索 Type 上声明的成员,而不搜索被简单继承的成员
BindingFlags.CreateInstance:表示调用构造函数。忽略 name。对其他调用标志无效

Unity5.4.x版本

var rowsData = arrayType.InvokeMember("rows", BindingFlags.Public | BindingFlags.GetProperty , null, arrayData, null);
tableRows = (rowsData as ICollection).GetEnumerator();

解决方法:

Unity2019版本

var rowsData = arrayType.InvokeMember("rows", BindingFlags.Public | BindingFlags.GetProperty | BindingFlags.Instance, null, arrayData, null);
tableRows = (rowsData as ICollection).GetEnumerator();
————————————————

标签:MissingMethodException,name,Unity5.4,成员,System,升级,BindingFlags,搜索,Reflection
来源: https://www.cnblogs.com/lovewaits/p/15954387.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有