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

I'm trying to deploy a Website in Azure, but I have this error: 我正在尝试在Azure中部署网站,但出现此错误:

D:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\Microsoft.Common.targets(1605,5): warning MSB3245: Could not resolve this reference. D:\\ Windows \\ Microsoft.NET \\ Framework \\ v4.0.30319 \\ Microsoft.Common.targets(1605,5):警告MSB3245:无法解决此引用。 Could not locate the assembly "System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL". 无法找到程序集“ System.Web.Http,版本= 4.0.0.0,区域性=中性,PublicKeyToken = 31bf3856ad364e35,processorArchitecture = MSIL”。 Check to make sure the assembly exists on disk. 检查以确保程序集在磁盘上。 If this reference is required by your code, you may get compilation errors. 如果您的代码需要此引用,则可能会出现编译错误。 [D:\\home\\site\\repository\\src\\Presentation\\Nop.Web.Framework\\Nop.Web.Framework.csproj] Mvc\\Api\\AuthorizeApiAttribute.cs(13,53): error CS0234: The type or namespace name 'Http' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) [D:\\ home \\ site \\ repository \\ src \\ Presentation \\ Nop.Web.Framework \\ Nop.Web.Framework.csproj] Mvc \\ Api \\ AuthorizeApiAttribute.cs(13,53):错误CS0234:类型或名称空间名称' Http”在“ System.Web”命名空间中不存在(您是否缺少程序集引用?)

I checked and the 'Copy Local' option is activated in the Solution. 我检查并在解决方案中激活了“复制本地”选项。 Any idea what's the problem? 知道有什么问题吗?

Check the Web.Config and make sure you are loading the correct versions and make sure you are referencing System.Net.Http.dll in .NET 4.0 or the NuGet Microsoft.AspNet.WebApi.Core . 检查Web.Config并确保您加载正确的版本,并确保在.NET 4.0或NuGet Microsoft.AspNet.WebApi.Core中引用System.Net.Http.dll The version you use must match the what you have in the web.config . 您使用的版本必须与web.config的版本匹配。

eg The Nuget for Microsoft.AspNet.WebApi.Core 5.2.3 might have System.Web.Http like: 例如,用于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>

Make sure your reference for System.Net.Http.dll is coming from the same source as other libraries. 确保对System.Net.Http.dll的引用与其他库来自同一来源。 which should be the bin folder of the project you're adding it to. 这应该是您要添加到的项目的bin文件夹。

Also make sure your packages.config file has a reference for that library: 还要确保您的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>

If it doesn't, add it as shown above with the correct target framework. 如果没有,请使用正确的目标框架如上所示添加它。

I believe more recent versions of the .NET framework (greater than 4.0) have System.Net.Http baked in. If this is an option, you could simply upgrade the .NET version. 我相信,较新版本的.NET Framework(大于4.0)具有System.Net.Http。如果可以选择,则可以简单地升级.NET版本。

暂无
暂无

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

相关问题 无法解析此引用。 找不到程序集 - Could not resolve this reference. Could not locate the assembly 从vs2013升级到vs2017后无法加载文件或程序集&#39;System.Web.Http,Version = 4.0.0.0&#39; - Could not load file or assembly 'System.Web.Http, Version=4.0.0.0' after upgrading from vs2013 to vs2017 无法使用 System.Web.Http 加载文件或程序集,版本 = 4.0.0.0 - Cannot load file or assembly with System.Web.Http, Version=4.0.0.0 无法加载文件或程序集&#39;System.Web.Http,Version = 5.2.2.0 - Could not load file or assembly 'System.Web.Http, Version=5.2.2.0 Azure webrole循环和“无法加载文件或程序集System.Web.Http 5.2.0.0” - Azure webrole cycling and “Could not load file or assembly System.Web.Http 5.2.0.0” .net core 3.0 无法加载文件或程序集“System.Web.Http 版本=5.2.7.0” - .net core 3.0 Could not load file or assembly 'System.Web.Http Version=5.2.7.0' 类型&#39;ApiController&#39;同时存在于&#39;System.Web.Http,Version = 4.0.0.0&#39;和&#39;System.Web.Http,Version = 5.2.3.0&#39;中 - The type 'ApiController' exists in both 'System.Web.Http, Version=4.0.0.0' and 'System.Web.Http, Version=5.2.3.0' 警告:无法解析此引用。 找不到程序集“PackageName”。 检查以确保程序集存在于磁盘上 - WARNING: Could not resolve this reference. Could not locate the assembly "PackageName". Check to make sure the assembly exists on disk 无法加载文件或程序集 'System.Web.Services,版本 = 4.0.0.0 - Could not load file or assembly 'System.Web.Services, Version=4.0.0.0 无法加载文件或程序集&#39;System.Web.Http.WebHost,版本= 4.0.0.0,区域性=中性,PublicKeyToken - Could not load file or assembly 'System.Web.Http.WebHost, Version=4.0.0.0, Culture=neutral, PublicKeyToken
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM