简体   繁体   中英

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

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:

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

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>

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

The type 'System.Object' is defined in an assembly that is not reference (MVC + PCL issue)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM