locked
Reference error for 'System.Net.Http, Version=2.0.0.0, RRS feed

  • Question

  • User380011454 posted

    Hi There,

    I recently changed the default .net version of my project from 4.5 -> 4.0 as my host does not support the new version as yet. I have a reference to the System.Net.Http, Version=4.0.0.0 in my project already. I tried to find the System.Net.Http, Version=2.0.0.0 but it can't see it in the list of references. Do I need to install another framework or something?

    -- error 

    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=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

    Saturday, August 10, 2013 9:27 PM

Answers

  • User-1454326058 posted

    Hi bullrout,

    Thanks for your post!

    We can’t find System.Net.Http reference when the project is based on .Net Framwork4.0.

    Base on you said that “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=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'”, I would like to know when did the error appear,did you build your project or run project on your .Net Framwork4.0 environment?

    Base on oned_gk said, we can find it should work in .Net4.5, however, I did some test as follows (My environment is based on .NET Framwork4.5):

    A:

    1. Create a new project that based on .Net Framwork4.5
    2. Add System.Net.Http reference to the project
    3. Add some code
    System.Net.Http.HttpClient c = new HttpClient();
    
    HttpMessageHandler h = null;

          4.  Change the project from 4.5 to 4.0

          5.  Build the project and click F5

          6.  Now it's fine

    B:

    1. Create a new project that based on .Net Framwork4.0
    2. Copy “System.Net.Http.dll”( C:\Windows\Microsoft.NET\Framework\v4.0.30319) to project and add it to my project
    3. Add some code
    System.Net.Http.HttpClient c = new HttpClient();
    
    HttpMessageHandler h = null;

     

          4.  Build the project and click F5

          5.  Now it's fine

    So, please try add a new project as I do and check the results.

    This reference below may benefit you:

    http://blogs.msdn.com/b/henrikn/archive/2012/04/29/using-nightly-nuget-packages-with-asp-net-web-stack.aspx

    Thanks

    Best Regards

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 12, 2013 5:47 AM

All replies

  • User-1716253493 posted
    Seem like it's only work in net 4.5, http://msdn.microsoft.com/en-us/library/system.net.http.aspx
    Saturday, August 10, 2013 10:25 PM
  • User-1454326058 posted

    Hi bullrout,

    Thanks for your post!

    We can’t find System.Net.Http reference when the project is based on .Net Framwork4.0.

    Base on you said that “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=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'”, I would like to know when did the error appear,did you build your project or run project on your .Net Framwork4.0 environment?

    Base on oned_gk said, we can find it should work in .Net4.5, however, I did some test as follows (My environment is based on .NET Framwork4.5):

    A:

    1. Create a new project that based on .Net Framwork4.5
    2. Add System.Net.Http reference to the project
    3. Add some code
    System.Net.Http.HttpClient c = new HttpClient();
    
    HttpMessageHandler h = null;

          4.  Change the project from 4.5 to 4.0

          5.  Build the project and click F5

          6.  Now it's fine

    B:

    1. Create a new project that based on .Net Framwork4.0
    2. Copy “System.Net.Http.dll”( C:\Windows\Microsoft.NET\Framework\v4.0.30319) to project and add it to my project
    3. Add some code
    System.Net.Http.HttpClient c = new HttpClient();
    
    HttpMessageHandler h = null;

     

          4.  Build the project and click F5

          5.  Now it's fine

    So, please try add a new project as I do and check the results.

    This reference below may benefit you:

    http://blogs.msdn.com/b/henrikn/archive/2012/04/29/using-nightly-nuget-packages-with-asp-net-web-stack.aspx

    Thanks

    Best Regards

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 12, 2013 5:47 AM
  • User380011454 posted

    Hi Starain, thanks for posting a very comprehensive answer. I followed your instructions (a) and that issue has gone now. 

    thank you.

    Friday, August 16, 2013 10:11 PM