Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

热更工程内调用实例方法System.Enum.HasFlag(enum) 在unity工程报错 #306

Closed
YeSH1024 opened this issue Nov 29, 2019 · 1 comment

Comments

@YeSH1024
Copy link

出现报错:
ArgumentException: Object of type 'ILRuntime.Runtime.Intepreter.ILEnumTypeInstance' cannot be converted to type 'System.Enum'.
System.RuntimeType.CheckValue (System.Object value, System.Reflection.Binder binder, System.Globalization.CultureInfo culture, System.Reflection.BindingFlags invokeAttr) (at <7ba07f088431485bb722f3b3373e87ee>:0)
System.Reflection.MonoMethod.ConvertValues (System.Reflection.Binder binder, System.Object[] args, System.Reflection.ParameterInfo[] pinfo, System.Globalization.CultureInfo culture, System.Reflection.BindingFlags invokeAttr) (at <7ba07f088431485bb722f3b3373e87ee>:0)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <7ba07f088431485bb722f3b3373e87ee>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <7ba07f088431485bb722f3b3373e87ee>:0)
ILRuntime.CLR.Method.CLRMethod.Invoke (ILRuntime.Runtime.Intepreter.ILIntepreter intepreter, ILRuntime.Runtime.Stack.StackObject* esp, System.Collections.Generic.IList`1[T] mStack, System.Boolean isNewObj) (at Assets/Scripts/Core/ILRuntime/CLR/Method/CLRMethod.cs:316)
ILRuntime.Runtime.Intepreter.ILIntepreter.Execute (ILRuntime.CLR.Method.ILMethod method, ILRuntime.Runtime.Stack.StackObject* esp, System.Boolean& unhandledException) (at Assets/Scripts/Core/ILRuntime/Runtime/Intepreter/ILIntepreter.cs:1797)
Rethrow as ILRuntimeException: Object of type 'ILRuntime.Runtime.Intepreter.ILEnumTypeInstance' cannot be converted to type 'System.Enum'.
IL_0051: call System.Boolean System.Enum::HasFlag(System.Enum)

@fatfatson
Copy link

同遇到,不过原因大致能理解 ,热更内定义的enum只是个自定义数据结构 ,对clr而言根本不知道有这么个枚举类型存在,拿它去调HasFlag这种函数,肯定会判this无效了。要么把枚举移到主工程去定义,要么自己重载HasFlag函数。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants