4

My project was building for .NET 4 and the version of System.Net.Http it was referencing was version 2. I just upgraded to .NET 4.5 because I wanted to do some of this routing stuff and it required me to reference version 4 of the System.Net.Http assembly which I did.

However, my webservices all return a HttpResponseMessage which doesn't exist in version 4 of the assembly.

How should I proceed?

NibblyPig
  • 51,118
  • 72
  • 200
  • 356

1 Answers1

6

Per MSDN it's still in the System.Net.Http assembly. Make sure that you are refrencing both the new System.Net and System.Net.Http assemblies.

http://msdn.microsoft.com/en-us/library/system.net.http.httpresponsemessage.aspx

I created a new project and added the System.Net and System.Net.Http assemblies and the HttpResponseMessage showed up fine.

nerdybeardo
  • 4,655
  • 23
  • 32
  • I see, adding `System.Net` version 4 made it work again (even though it's in `System.Net.Http`) however adding that library has broken something else with `MapHttpRoute`. I will look into it, thank you. – NibblyPig Jan 01 '13 at 13:18
  • Rebuilding it I get this "Error 1 The type 'System.Net.Http.HttpResponseMessage' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Net.Http, Version=2.0.0.0...." I thought it was fixed, but apparently not... – NibblyPig Jan 01 '13 at 13:20
  • I think it's possible that because I converted the solution from .net 4 to .net 4.5 that it has gotten confused, any ideas on how to sort this mess out? – NibblyPig Jan 01 '13 at 13:21
  • 1
    I've fixed it by deleting an obselete reference. The problem now is that HttpResponseMessage is different, it doesn't support `` so I am still stuck on converting the code across. – NibblyPig Jan 01 '13 at 13:26
  • Is there any reference to "System.Net.Http, Version=2.0.0.0..." in your web.config file under the assemblies section? If so remove it. – nerdybeardo Jan 01 '13 at 13:26
  • Check out this post on the missing generic HttpResposneMessage http://aspnetwebstack.codeplex.com/discussions/355170, aparently it was removed because it wasn't type safe. – nerdybeardo Jan 01 '13 at 13:31
  • Cheers, what I have done is started a new project from scratch and it has fixed pretty much all of the issues. The last issue with the removal of the generic HttpResponseMessage I found a simple solution for, thanks :) – NibblyPig Jan 01 '13 at 15:49
  • @NibblyPig - and what was this simple solution? regards, The Necromancer – pentaphobe Mar 17 '17 at 02:55
  • @pentaphobe Hmm this was 4 years ago! There is another way to create a response message, something like `request.CreateHttpResponse()` but I can't remember off hand. – NibblyPig Mar 17 '17 at 09:42