文章内容
2017/8/5 17:23:42,作 者: 黄兵
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException
今天在写代码的时候报如下错误:
“Microsoft.CSharp.RuntimeBinder.RuntimeBinderException”类型的异常在 System.Core.dll 中发生,但未在用户代码中进行处理
其他信息: 无法将类型“System.Threading.Tasks.Task<System.Collections.Generic.List<MyBlog.Models.BlogViewModel>>”隐式转换为“System.Collections.IEnumerable”。存在一个显式转换(是否缺少强制转换?)
错误截图:
看一下错误代码:
var blogSummaryList = NoTopic.Select(b => new BlogViewModel { AuthorName = b.User.UserName, CommentsCount = b.Comments.Count, CreationTime = b.CreationTime, Id = b.Id, Overview = b.Body, Title = b.Title }).ToListAsync();
解决方案:
var blogSummaryList = await NoTopic.Select(b => new BlogViewModel { AuthorName = b.User.UserName, CommentsCount = b.Comments.Count, CreationTime = b.CreationTime, Id = b.Id, Overview = b.Body, Title = b.Title }).ToListAsync(); ViewBag.blogSummaryList = blogSummaryList;
黄兵的个人博客原创。
转载请注明出处:黄兵的个人博客 - Microsoft.CSharp.RuntimeBinder.RuntimeBinderException
评论列表