Asp.net MVC EditorFor“类型'System.Object'是在未引用的程序集中定义的"错误 [英] Asp.net MVC EditorFor "The type 'System.Object' is defined in an assembly that is not referenced" error

查看:54
本文介绍了Asp.net 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'是在未引用的程序集中定义的"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆