HttpRequestMessage could not be found, yet System.Net.Http is referenced

the type or namespace name 'http' does not exist in the namespace 'system net
the type or namespace name 'httpresponsemessage' could not be found
webrequesthandler could not be found location nuget vs framework not found .net 4 not found
the referenced component '' could not be found

I have a new .Net 4.5.2 (checked that this is the target framework) Web API Application (in VS 2015). I have referenced System.Net.Http, and as you can see the version is

In my Filter/Attribute I am trying to reference HttpRequestMessage which is in the System.Net.Http namespace (I have the correct using at the top of my file), yet am getting the message that

The type 'HttpRequestMessage' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Net.Http, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

And although I can't reference that class, I can browse to it in the Object Exploerer (I assume this uses the .xml file of the same name next to the .dll).

I have tried (edit: as well as the usual restarting VS and rebuilds etc):

  1. Removing and re-adding the reference (from both the Framework and Extensions - although I'm certain it's meant to be the Framework version, I was getting desparate)
  2. Installing from Nuget and referencing the version in my local packages folder, which seemed to just default back to the system-wide version.
  3. Reinstalling all my dependencies in Nuget PM with: update-package -reinstall -ignoreDependencies
  4. Adding the assembly manually to the web.config Adding the assembly manually to the .csproj file

[Edit: Solution:

OK, I created a few new VS Web API projects (and solutions) to see if I could reproduce the problem. In the end I created a new "Filters" folder, created a new Filter class in there, copied the contents of my pared-down original over, and lo-and-behold HttpRequestMessage was recognised. Did the same thing going back the other way (my filter was originally created in an App_Code folder) and it was still working. I think perhaps there was an unseen reference to an old System.Net.Http that was throwing a spanner in the works and even though I may have commented out the code that called it, somehow it was being remembered. That's just a guess. But anyway, paring it down to barest bones and going from there was the final approach that led to a solution.]

I also managed to resolve this by moving my custom RouteConstraints out of the App_Code folder. Just added a new folder to my project and copied them there.

Reference to System.Net.Http breaks after changing , There is a nuget package reference: When in net471 mode, I can I tried removing the package, clearing it from cache, reinstall it, but no luck. name ' HttpRequestMessage' could not be found (are you missing a using� I have manually moved from packages.config to packagereference and found this: Visual Studio 2017 - Could not load file or assembly 'System.Runtime, Version=' or one of its dependencies It's says that there should be a migrate option. But I did not see it and had the .config file removed.

I've tried this highly suggested solution (on Web.Config)

    <compilation debug="true" targetFramework="4.5" />
    <compilation debug="true" targetFramework="4.0">
        <add assembly="System.Data.Entity, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

But unfortunately, this didn't work me. At last, I've found a solution (this worked for me)

Right-click the References folder > Add Reference... Expand Assemblies on the left side of the window and select Framework. Scroll to and select System.Net.Http in the list of assemblies. Make sure the box next to System.Net.Http is checked, then click OK. Rebuild the project.

System.Net.Http NuGet broken for .NET 4.7.2 � Issue #26131 � dotnet , 2, the web app does compile, but I end up getting a runtime error complaining about a missing System.Net.Http reference (in this case, it's� This project illustrates how referencing a 4.7.2 project from a .net standard 2.0 project where System.Net.Http is involved triggers the following warning on build. Found conflicts between different versions of "System.Net.Http" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed.

If you're coming from creating web sites, but are now creating a web application, don't add the App_Code folder or any code into it as each class file will either be set to "Content" (click on the class, look in the Properties pane under "Build Action") and so won't be picked up by Intellisense in the rest of the application, or you can set to "Compile" but then that has its own problems at release time: See Vishel Joshi's blog all about it.

“type or namespace name … could not be found” errors building , But on TC I can't build Web solution (but can all console apps and class libraries). 'HttpRequestMessage' could not be found (are you missing a using directive or System.Http and System.Http.Net were not referenced properly. Solution - to� I have absolutely no clue, why the System.Net.Http assembly is not found at all – there is even a assembly reference in my class library project to the .Net Framework Assembly “System.Net.Http”.

I am having the same problem, (which is how I stumbled on this question) and there is one thing that I noticed that nobody seems to have latched onto yet.

I am building a WebApi2 application, and I added in a class library to turn into an nunit test library. I started getting conflicts with System.Web.Http. It appears that the webapi2 uses, where other things will try to default to

Make sure that you are using the correct version of System.Web.Http, and that you also have the System.Net.Http assembly referenced. Once both assemblies were referenced and running the same version numbers across all solutions, all problems were resolved. VS doesn't always load the correct versions by itself.

System.Net.Http is driving me insane. : csharp, NET 4.7.1, I've had a torrent of issues with System.Net.Http .dll references on our Most of the time I can run it just fine on my own machine, but then the build apps deployed on our servers might complain that System.Net.Http is missing� When I change net471 to net472 in my .csproj file, it can't find System.Net.Http anymore, and the build fails. There is a nuget package reference: When in net471 mode, I can navigate to the package // C:\Users\Bas.nuget\packages\system.n

In my case, willing to actually use dynamically compiled files inside the App_Code, I had to add explicitly the assembly in the compilation node of the Web.Config:

  <compilation targetFramework="4.7.2">
      <add assembly="System.Net.Http, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>

This solved my case. Of course, adjust the target framework according to your project needs.

NuGet Gallery, System.Net.Http 4.3.4. Provides a programming interface for modern HTTP to consume web services over HTTP and HTTP components that can be used by Commonly Used Types: System.Net.Http.HttpResponseMessage paket add System.Net.Http --version 4.3.4. The NuGet Team does not provide� Error 29 The type 'System.Net.Http.HttpMessageHandler' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Net.Http, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

System.Net.Http Namespace, System.Net.Http Namespace. The System.Net.Http namespace provides a HttpRequestMessage and HttpResponseMessage - HTTP messages as defined in then the app should stream those downloads and not use the default buffering. After upgrading my solution to .NET 4.7.2 in hope that I could finally get rid of System.Net.Http.dll hell, I got the same error: Could not load file or assembly 'System.Net.Http, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

HttpResponseMessage Class (System.Net.Http), Remarks. A common way to get an HttpResponseMessage is from one of the HttpClient.SendAsync(HttpRequestMessage) methods. Constructors� The System.Net.Http namespace provides a programming interface for modern HTTP applications.

Dismiss Join GitHub today GitHub is home to over 50 million , Workaround: Target System.Net.Http.WinHttpHandler NuGet package instead. (the normal default handler for HttpClient) but will support HTTP/2.0 protocol. HttpClient(handler); var request = new HttpRequestMessage(HttpMethod. This looks like it might be due to missing security attributes on the out-of-band System. a. Building will generate the warning "Found conflicts between different versions of 'System.Net.Http' that could not be resolved" b. Running the app will generate a run-time exception: "Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'System.Net.Http, Version="

  • Could it be VS is just being stupid? Try restarting your IDE.
  • You might also need to provide binding redirect for this assembly in your web.config/app.config for Could you confirm that is present?
  • Try to set it copy local and then restore packages. If it didn't help set specific version equal true.
  • @James_Parsons Yep, tried that (sorry, should have added to list :) )
  • @KnightFox, in web.config I'd tried: <dependentAssembly> <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" /> <bindingRedirect oldVersion="" newVersion="" /> </dependentAssembly>
  • Yep, I've since read that keeping anything in App_Code folder is an issue for anything (inc. web apps) but websites.