繁体   English   中英

天蓝色错误部署无法解析此参考。 无法找到程序集System.Web.Http,版本= 4.0.0.0

[英]Deploying in azure error Could not resolve this reference. Could not locate the assembly System.Web.Http, Version=4.0.0.0

我正在尝试在Azure中部署网站,但出现此错误:

D:\\ Windows \\ Microsoft.NET \\ Framework \\ v4.0.30319 \\ Microsoft.Common.targets(1605,5):警告MSB3245:无法解决此引用。 无法找到程序集“ System.Web.Http,版本= 4.0.0.0,区域性=中性,PublicKeyToken = 31bf3856ad364e35,processorArchitecture = MSIL”。 检查以确保程序集在磁盘上。 如果您的代码需要此引用,则可能会出现编译错误。 [D:\\ home \\ site \\ repository \\ src \\ Presentation \\ Nop.Web.Framework \\ Nop.Web.Framework.csproj] Mvc \\ Api \\ AuthorizeApiAttribute.cs(13,53):错误CS0234:类型或名称空间名称' Http”在“ System.Web”命名空间中不存在(您是否缺少程序集引用?)

我检查并在解决方案中激活了“复制本地”选项。 知道有什么问题吗?

检查Web.Config并确保您加载正确的版本,并确保在.NET 4.0或NuGet Microsoft.AspNet.WebApi.Core中引用System.Net.Http.dll 您使用的版本必须与web.config的版本匹配。

例如,用于Microsoft.AspNet.WebApi.Core 5.2.3的Nuget可能具有System.Web.Http如:

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
        </dependentAssembly>
    </assemblyBinding>
</runtime>

确保对System.Net.Http.dll的引用与其他库来自同一来源。 这应该是您要添加到的项目的bin文件夹。

还要确保您的packages.config文件具有该库的引用:

  <?xml version="1.0" encoding="utf-8"?>
      <package id="System.Reflection.Extensions" version="4.3.0" targetFramework="portable45-net45+win8+wp8+wpa81" />
      <package id="System.Runtime.Extensions" version="4.3.0" targetFramework="portable45-net45+win8+wp8+wpa81" />
      <package id="System.Net.Http" version="4.0.0" targetFramework="portable45-net45+win8+wp8+wpa81" />
    </packages>

如果没有,请使用正确的目标框架如上所示添加它。

我相信,较新版本的.NET Framework(大于4.0)具有System.Net.Http。如果可以选择,则可以简单地升级.NET版本。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM