简体   繁体   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>
}

This line Line 32: @Html.EditorFor(model => model.Employees) gives the following Error 第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'.

I have used this similiar approach in another project which did not give this error. 我在另一个没有出现此错误的项目中使用了这种类似的方法。

Look for this in your web.config: 在web.config中查找:

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

Add the System.Runtime assembly as follows: 添加System.Runtime程序集,如下所示:

 <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: 这通常是由MVC和PCL引起的,详见下文:

The type 'System.Object' is defined in an assembly that is not reference (MVC + PCL issue) 类型'System.Object'是在非引用的程序集中定义的(MVC + PCL问题)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法将类型'System.Nullable`1'强制转换为'System.Object'类型 - ASP.NET MVC - Unable to cast the type 'System.Nullable`1' to type 'System.Object' - ASP.NET MVC “System.Object”类型在未引用的程序集中定义。 您必须添加对程序集 .netstandard 的引用 - The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard 投system.object到List<model> asp.net MVC</model> - cast system.object to List<model> asp.net mvc Protobuf网络未告知要序列化System.Object,但仍会收到错误:没有为以下类型定义序列化程序:System.Object - Protobuf net not told to Serialize a System.Object but still get error: No serializer defined for type: System.Object 类型“异常”是在ASP.NET 5 RC1中未引用的程序集中定义的 - The type 'Exception' is defined in an assembly that is not referenced in ASP.NET 5 RC1 ASP.Net DNX Core CLR与StructureMap.Dnx有关的问题:类型“对象”是在未引用的程序集中定义的 - ASP.Net DNX Core CLR issue with StructureMap.Dnx: The type 'Object' is defined in an assembly that is not referenced 对象(通用)的 Protobuf-net 序列化抛出错误没有为类型定义序列化程序:System.Object - Protobuf-net serialization of object (generic) throws error No serializer defined for type: System.Object 预定义类型“System.Object”未定义或导入 .net 4.6 - Predefined type 'System.Object' is not defined or imported .net 4.6 Asp.net c#,无法创建类型为&#39;System.Object&#39;的常量值 - Asp.net c#, Unable to create a constant value of type 'System.Object' ProtoBuf-Net:没有为类型定义序列化程序:System.Object - ProtoBuf-Net: No serializer defined for type: System.Object
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM