【问题标题】:'System.Net.Http.HttpContent' is defined in an assembly that is not referenced'System.Net.Http.HttpContent' 在未引用的程序集中定义
【发布时间】:2013-09-26 23:04:47
【问题描述】:

我在针对 .Net Framework 4.5 版的 .Net c# MVC 应用程序中遇到以下错误:

The type 'System.Net.Http.HttpContent' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

我在项目中添加了引用,我什至编辑了 web.config 以包含对以下程序集的引用:

<system.web>
  <compilation debug="true" targetFramework="4.0"/>

不幸的是,我找不到任何解释为什么会发生异常。有没有人有同样的例外?

【问题讨论】:

  • 您的错误表明 Version=2.0.0.0 并且您的目标框架是 .Net 4.5,可能就是冲突所在;到你引用的dll版本..
  • 您是在暗示我引用的是版本 2 框架而不是最新版本吗?让我们试一试...
  • 运气不好...仍然不知道为什么会这样。

标签: c# .net asp.net-mvc exception reference


【解决方案1】:

考虑检查 machine.config 和其他配置文件。在上述情况下,损坏的 machine.config 是问题所在。

【讨论】:

    猜你喜欢
    • 2014-04-08
    • 2011-07-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-16
    • 2014-08-15
    • 2016-05-01
    相关资源
    最近更新 更多