Asp.net MVC EditorFor "Type" System.Object "is defined in an assembly that does not have an" 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 used this similar approach in another project that did not give this error.

+4
source share
1 answer

Look for this in your web.config:

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

Add the assembly System.Runtimeas 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 by MVC and PCL, as described in the following article:

The type "System.Object" is defined in an assembly that is not a reference (a problem with MVC + PCL)

+14
source

All Articles