Asp.net MVC EditorFor“类型'System.Object'是在未引用的程序集中定义的"错误

编程入门 行业动态 更新时间:2024-10-25 00:37:08
本文介绍了Asp MVC EditorFor“类型'System.Object'是在未引用的程序集中定义的"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 @using (Html.BeginForm("Index", "Employees", FormMethod.Post, new { encType = "multipart/form-data", name = "EmployeeForm" })) { <table class="table table-bordered table-condensed table-striped"> <tr> <th> Name </th> <th> Surname </th> <th> ID Number </th> <th> Email </th> <th> Birthdate </th> <th> Action </th> </tr> @Html.EditorFor(model => model.Employees) </table> }

这行第 32 行:@Html.EditorFor(model => model.Employees) 给出以下错误

This line Line 32: @Html.EditorFor(model => model.Employees) gives the following Error

CS0012: The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

我在另一个没有出现此错误的项目中使用了这种类似的方法.

I have used this similiar approach in another project which did not give this error.

推荐答案

在您的 web.config 中查找:

Look for this in your web.config:

<compilation debug="true" targetFramework="4.5"/>

按如下方式添加 System.Runtime 程序集:

Add the System.Runtime assembly as follows:

<compilation debug="true" targetFramework="4.5"> <assemblies> <add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </assemblies> </compilation>

这通常是由 MVC 和 PCL 引起的,详见以下文章:

This is usually caused due to MVC and PCL as detailed in the following article:

在非引用的程序集中定义了类型System.Object"(MVC + PCL 问题)

更多推荐

Asp.net MVC EditorFor“类型'System.Object'是在未引用的程序集中定义的"错误

本文发布于:2023-11-05 09:16:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1560456.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:是在   定义   错误   类型   程序

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!