【发布时间】:2014-08-15 07:27:14
【问题描述】:
我在我的项目中安装了一个 Microsoft ASP.NET Web API Compression nuget 包,并在 Register 方法中的 WebApiconfig 中添加了一行,如此链接所示https://www.nuget.org/packages/Microsoft.AspNet.WebApi.MessageHandlers.Compression/
GlobalConfiguration.Configuration.MessageHandlers.Insert(0, new CompressionHandler(new GZipCompressor(), new DeflateCompressor()));
还将以下代码添加到 web.config 文件中
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</assemblies>
</compilation>
但我收到一个错误
错误 1 类型 'System.Object' 是在一个不是 参考。您必须添加对程序集“System.Runtime”的引用, 版本=4.0.0.0,文化=中性, PublicKeyToken=b03f5f7f11d50a3a'。 D:....\App_Start\WebApiConfig.cs
编译器抱怨 GlobalConfiguration 类出现上述错误。 我正在使用 >NET Framework 4.5
【问题讨论】:
-
它在抱怨,因为它需要 4.0 版本,而您的项目的目标是 4.5 版本。
-
@Rahul 将您的回复转换为答案以及如何解决问题的说明会很棒。
标签: asp.net