本文介绍了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'是在未引用的程序集中定义的"错误
发布评论