Home

Error Could not load file or assembly System.Web.Http in WebApi VB.NET Project

Hallo,

I am using the latest LinqPad version (v5.08.01 AnyCPU)

I have a WebApi project with a code-first Entity Framework model. The following NuGet packages are installed
Id Versions
-- --------
DynamicLINQ {1.0}
EntityFramework {6.1.3}
EntityFramework.de {6.1.3}
EntityFramework.Functions {1.3.1}
LinqKit {1.1.3.1}
Microsoft.AspNet.WebApi {5.2.3}
Microsoft.AspNet.WebApi.Client {5.2.3}
Microsoft.AspNet.WebApi.Client.de {5.2.3}
Microsoft.AspNet.WebApi.Core {5.2.3}
Microsoft.AspNet.WebApi.Core.de {5.2.3}
Microsoft.AspNet.WebApi.OData {5.3.1}
Microsoft.AspNet.WebApi.WebHost {5.2.3}
Microsoft.AspNet.WebApi.WebHost.de {5.2.3}
Microsoft.Data.Edm {5.6.0}
Microsoft.Data.OData {5.6.0}
Microsoft.Net.Compilers {1.0.0}
Newtonsoft.Json {6.0.4}
System.Spatial {5.6.0}

I created a new query in LinqPad. Added all the NuGet Packeges.
I try to add a conncetion using the Entity Framework (DbContext V4/V5/V6) Option.
I add the path to the dll generated in the WebApi porject. I get the following error message:

Could not load file or assembly 'System.Web.Http, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

The Web Api project is referencing Version 5.2.3.0 (Specific Verion is set to false).
I added the following to the app.config:
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
      </dependentAssembly>	  
I still get the error message.

Any help would be appreciated!


Comments

  • linqpad 5 is not support version 5.2.3.0 of System.Web.Http
    you need to unInstall Microsoft.AspNet.WebApi.Core.5.2.2
    and install Microsoft.AspNet.WebApi.Core.5.2.3
    steps:
    1. Open Package Manager Console
    2. Run This Command :UnInstall-Package Microsoft.AspNet.WebApi.Core -Version 5.2.3
    3. Run this Command Install-Package Microsoft.AspNet.WebApi.Core -Version 5.2.2
  • edited December 2016
    I'm getting the same error when adding an Entity Framework DbContext Connection:

    Could not load file or assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

    I verified I am using the following versions:
    Microsoft.AspNet.WebApi.Core -Version 5.2.2
    Microsoft.AspNet.WebApi -Version 5.2.2

    What else can I check?

    Tia.
    ScottM
  • I am encountering the same error as scottm when trying to choose DbContext:

    Could not load file or assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

    The project is using the following versions:
    Microsoft.AspNet.WebApi.Core - Version 5.2.7

    LinqPad Version - Version 5.41.00

    Any indicators as to where I can go from here would be appreciated.

Sign In or Register to comment.