Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

ViewComponent View() fails on CoreCLR with IEnumerable<> passed in #1354

Closed
@BrennanConroy

Description

@BrennanConroy

I have a ViewComponent and on InvokeAsync I grab some data from a database and give it to the View.

var query = Context.SomeTable.ToArray();

return View(query.Select(e => new Model
{
Value = e.Val;
Count = e.Count;
}));

A stack trace is at the bottom for the above.

If I Instead do:

var temp = query.Select(e => new Model
{
Value = e.Val;
Count = e.Count;
}).ToArray();

return View(temp);
That will work on Core now.

Stack trace:
System.MethodAccessException: Attempt by method 'Microsoft.AspNet.Mvc.PropertyHelper.MakeFastPropertyGetter(System.Reflection.PropertyInfo)' to access method 'System.Linq.Enumerable+Iterator1<System.__Canon>.get_Current()' failed. at System.Delegate.BindToMethodInfo(Object target, IRuntimeMethodInfo method, RuntimeType methodType, DelegateBindingFlags flags) at System.Delegate.UnsafeCreateDelegate(RuntimeType rtType, RuntimeMethodInfo rtMethod, Object firstArgument, DelegateBindingFlags flags) at System.Delegate.CreateDelegateInternal(RuntimeType rtType, RuntimeMethodInfo rtMethod, Object firstArgument, DelegateBindingFlags flags, StackCrawlMark& stackMark) at System.Reflection.RuntimeMethodInfo.CreateDelegateInternal(Type delegateType, Object firstArgument, DelegateBindingFlags bindingFlags, StackCrawlMark& stackMark) at System.Reflection.RuntimeMethodInfo.CreateDelegate(Type delegateType) at Microsoft.AspNet.Mvc.PropertyHelper.MakeFastPropertyGetter(PropertyInfo propertyInfo) at Microsoft.AspNet.Mvc.PropertyHelper..ctor(PropertyInfo property) at Microsoft.AspNet.Mvc.PropertyHelper.CreateInstance(PropertyInfo property) at Microsoft.AspNet.Mvc.PropertyHelper.<>c__DisplayClass0.<GetProperties>b__3(PropertyInfo p) at System.Linq.Enumerable.WhereSelectArrayIterator2.MoveNext()
at System.Linq.Buffer1..ctor(IEnumerable1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source) at Microsoft.AspNet.Mvc.PropertyHelper.GetProperties(Type type, Func2 createPropertyHelper, ConcurrentDictionary2 cache) at Microsoft.AspNet.Mvc.PropertyHelper.GetProperties(Type type) at Microsoft.AspNet.Mvc.ModelBinding.AssociatedMetadataProvider1.CreateTypeInformation(Type type, IEnumerable1 associatedAttributes) at Microsoft.AspNet.Mvc.ModelBinding.AssociatedMetadataProvider1.GetTypeInformation(Type type, IEnumerable1 associatedAttributes) at Microsoft.AspNet.Mvc.ModelBinding.AssociatedMetadataProvider1.GetMetadataForType(Func1 modelAccessor, Type modelType) at Microsoft.AspNet.Mvc.ViewDataDictionary.SetModel(Object value) at Microsoft.AspNet.Mvc.ViewDataDictionary1.SetModel(Object value)
at Microsoft.AspNet.Mvc.ViewDataDictionary`1.set_Model(TModel value)
at Microsoft.AspNet.Mvc.ViewComponent.View[TModel](String viewName, TModel model)
at Microsoft.AspNet.Mvc.ViewComponent.View[TModel](TModel model)
at Namespace.Component.MyCompComponent.d__1.MoveNext() in FileName\Components\MyComp.cs:line 80

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions