[英]Asp.net MVC EditorFor “The type 'System.Object' is defined in an assembly that is not referenced” error
@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>
}
This line Line 32: @Html.EditorFor(model => model.Employees) gives the following Error 第32行:@ Html.EditorFor(model => model.Employees)给出以下错误
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. 我在另一个没有出现此错误的项目中使用了这种类似的方法。
Look for this in your web.config: 在web.config中查找:
<compilation debug="true" targetFramework="4.5"/>
Add the System.Runtime
assembly as follows: 添加
System.Runtime
程序集,如下所示:
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</assemblies>
</compilation>
This is usually caused due to MVC and PCL as detailed in the following article: 这通常是由MVC和PCL引起的,详见下文:
The type 'System.Object' is defined in an assembly that is not reference (MVC + PCL issue) 类型'System.Object'是在非引用的程序集中定义的(MVC + PCL问题)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.