簡體   English   中英

Asp.net MVC EditorFor“類型'System.Object'是在未引用的程序集中定義的”錯誤

[英]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>
}

第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'.

我在另一個沒有出現此錯誤的項目中使用了這種類似的方法。

在web.config中查找:

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

添加System.Runtime程序集,如下所示:

 <compilation debug="true" targetFramework="4.5">
      <assemblies>     
        <add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />   
      </assemblies>
    </compilation>

這通常是由MVC和PCL引起的,詳見下文:

類型'System.Object'是在非引用的程序集中定義的(MVC + PCL問題)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM