0
votes

I'm trying to deploy a Website in Azure, but I have this error:

D:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Web.Http, Version=4.0.0.0, Culture=neutral, 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?)

I checked and the 'Copy Local' option is activated in the Solution. Any idea what's the problem?

2

2 Answers

0
votes

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. The version you use must match the what you have in the web.config.

e.g. The Nuget for Microsoft.AspNet.WebApi.Core 5.2.3 might have System.Web.Http like:

<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>
0
votes

Make sure your reference for System.Net.Http.dll is coming from the same source as other libraries. which should be the bin folder of the project you're adding it to.

Also make sure your packages.config file has a reference for that library:

  <?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.