[英]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.