【问题标题】:The type System.Data.Objects.ObjectResult is defined in an assembly that is not referenced [duplicate]System.Data.Objects.ObjectResult 类型在未引用的程序集中定义[重复]
【发布时间】:2017-11-23 21:52:57
【问题描述】:

在控制台应用程序中获取error

类型“System.Data.Objects.ObjectResult`1”在未引用的程序集中定义。您必须添加对程序集 'System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'的引用

但不知道如何在 app.config 中为这个程序集添加引用?

我尝试添加为:

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Data.Entity" publicKeyToken="b77a5c561934e089" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>

但这不起作用。如何解决?

【问题讨论】:

  • 这是绑定重定向,而不是引用。
  • @CodeCaster,那我怎样才能摆脱这个错误呢?
  • 通过添加参考资料,该参考资料已在网络上完整记录。

标签: c# asp.net-mvc console-application


【解决方案1】:

您应该通过Add reference 对话框添加引用。您可以通过右键单击解决方案资源管理器中的引用到达那里:

顺便说一句:nuget 包通常需要 System.Data.EntityEntityFramework 例如。如果是,您应该添加 nuget 包。

并添加参考:

【讨论】:

  • 解决了问题,我刚刚添加了对 EntityFramework 的引用,而不是 'Sytem.Data.Entity'。
猜你喜欢
  • 2011-08-16
  • 2014-08-15
  • 2016-05-01
  • 2018-01-10
  • 1970-01-01
  • 1970-01-01
  • 2023-03-28
  • 2018-12-26
  • 1970-01-01
相关资源
最近更新 更多