资讯详情

[Unity][C#][ILRuntime]Dictionary嵌套错误

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.   at System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) [0x0001e] in <9577ac7a62ef43179789031239ba8798>:0    at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)   at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <9577ac7a62ef43179789031239ba8798>:0     --- End of inner exception stack trace ---   at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00048] in <9577ac7a62ef43179789031239ba8798>:0    at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0    at 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) [0x00200] in E:\ui\Awaken - 副本\Library\PackageCache\com.ourpalm.ilruntime@1.6.6\CLR\Method\CLRMethod.cs:316    at ILRuntime.Runtime.Intepreter.ILIntepreter.Execute (ILRuntime.CLR.Method.ILMethod method, ILRuntime.Runtime.Stack.StackObject* esp, System.Boolean& unhandledException) [0x03362] in E:\ui\Awaken - 副本\Library\PackageCache\com.ourpalm.ilruntime@1.6.6\Runtime\Intepreter\ILIntepreter.cs:1839  UnityEngine.Debug:LogError(Object) ILRuntime.Runtime.Generated.UnityEngine_Debug_Binding:LogError_0(ILIntepreter, StackObject*, IList`1, CLRMethod, Boolean) (at Assets/ILRuntime/Generated/UnityEngine_Debug_Binding.cs:50) ILRuntime.Runtime.Intepreter.ILIntepreter:Execute(ILMethod, StackObject*, Boolean&) (at Library/PackageCache/com.ourpalm.ilruntime@1.6.6/Runtime/Intepreter/ILIntepreter.cs:1823) ILRuntime.Runtime.Enviorment.InvocationContext:Invoke() (at Library/PackageCache/com.ourpalm.ilruntime@1.6.6/Runtime/Enviorment/InvocationContext.cs:333) ILRuntime.Runtime.Intepreter.MethodDelegateAdapter`1:InvokeILMethod(TextAsset) (at Library/PackageCache/com.ourpalm.ilruntime@1.6.6/Runtime/Intepreter/DelegateAdapter.cs:410) <loadJsonDataConf>d__19:MoveNext() (at Assets/Sprite/ResMgr.cs:196) UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator) <CheckLoad>d__18:MoveNext() (at Assets/Sprite/ResMgr.cs:165) UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator) ResMgr:Update() (at Assets/Sprite/ResMgr.cs:135)

嵌套Dictionary关键字中没有循环变量 i 的值。

...             //Dictionary<int, List<testClass>> test = new Dictionary<int, List<testClass>>(); ...             List<int> test1 = new List<int>(_test.Keys);             for (int i = 0; i < test1.Count; i  )             {                 Debug.Log("   test :" i "/"  test[i]   "/Count:"   test [i].Count);//错误             }////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Debug.Log("   test :" i "/"  test[test1[i]]   "/Count:"   test [test1[i]].Count); ... class testClass { ... int id; string name; ... }

标签: ilme重型连接器ag

锐单商城拥有海量元器件数据手册IC替代型号,打造 电子元器件IC百科大全!

锐单商城 - 一站式电子元器件采购平台