-
Notifications
You must be signed in to change notification settings - Fork 86
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
List<T> cast error #91
Comments
i changed AnonymousTypeWrapper.cs modify TryGetMember method
` |
thanks! |
adoconnection
added a commit
that referenced
this issue
Jan 17, 2022
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
when i try to user a List<KeyValuePair<string,string>> or a Dictionary<string,string> like this:
@foreach (var item in Model.Languages){ <option value="@(item.Key)">@(item.Value)</option> }
got this error:
Unable to cast object of type 'System.Collections.Generic.List
1[System.Collections.Generic.KeyValuePair
2[System.String,System.String]]' to type 'System.Collections.Generic.IEnumerable`1[System.Object]'.error stackTrace is
at System.Runtime.CompilerServices.CastHelpers.ChkCastAny(Void* toTypeHnd, Object obj)
at RazorEngineCore.AnonymousTypeWrapper.TryGetMember(GetMemberBinder binder, Object& result)
at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
at TemplateNamespace.Template.d__0.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at RazorEngineCore.RazorEngineCompiledTemplate.d__12.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at RazorEngineCore.RazorEngineCompiledTemplate.Run(Object model)
i upgrade to dotnet6 ,before this update ,this code runs very well.
then i change model to
Languages = list.Select(v=>(object)v).ToList();
it works!!
hope to fix this issue.
The text was updated successfully, but these errors were encountered: