none
TRYING to use HttpClient, HttpResponseMessage, HttpContent RRS feed

  • Question

  • Good evening, Gurus.

    I'm having a problem using HttpClient/HttpResponse/HttpContent in a Winform app using VS2017.

    The problem seems to be finding the namespace 'System.Net.Http …. the System.Net is fine and has been working for at least seven years but the statements

    "using System.Net.Http"     and    "using System.Threading.Tasks"  are failing in a Winform app.

    and when I opened the list of references in Solution Explorer, I see "System.Net" and "System.Threading", but no "System.Net.Http" or "System.Threading.Tasks".

    However, those statements work just fine in a simple console app, so the requisite DLL must be SOMEWHERE on my 'chine..

    So, what up ?

    Thanks for your help with this very vexing problem.

    Friday, December 28, 2018 4:26 AM

Answers

  • Well, THAT was quite a horror-show, but it does seem to be working now.

    I use the term 'horror-show' cuz it involved getting something from NuGet. That was certainly fun!  But, the good news is that after about three hours, and a lotta searching of the internet (Thank You, Google!), it does seem to be working now … and, in a Winform app.

    T'morra I will move the function to the actual target (to keep things simple, I placed it in a throw-away, test WinApp). I expect that will go smoothly. I think the battle is largely over now. We'll see what happens t'morra.

    So, thank you, Viorel. You got me started on the right path.

    'preciate your help.

    • Marked as answer by Lincoln_MA Saturday, December 29, 2018 2:08 AM
    Saturday, December 29, 2018 2:07 AM

All replies

  • Add a reference to System.Net.Http. In order to use HttpResponse, also add System.Web.

    Also set a modern or latest version of .NET Framework in Project Properties (e.g. 7.1), because some of the classes and namespaces were not available in the past.

    • Marked as answer by Lincoln_MA Friday, December 28, 2018 6:37 AM
    • Unmarked as answer by Lincoln_MA Friday, December 28, 2018 6:29 PM
    Friday, December 28, 2018 6:11 AM
  • Thanks so  much for your help, Viorel.

    It's kinda late here now, but I'll try your suggestions(s) first thing t'morra morning.

    Thanks again.

    UPDATE:   Hmmm, there's gotta be sumthin' else goin' on.  The Framework HAD been at 3.5. Just downloaded and set the target Framework to 4.7.1 (download was successful).

    That cleared up the ...Tasks reference, but I'm still missing System.Net.Http reference. And what's worse, when I look to see what's available to System.Net, there a buncha options, but "Http" ain't one of'em.

    I am (and was) referencing System.Web but neither that nor System.Threading.Tasks is  referenced (i.e.they're 'grayed out')


    • Edited by Lincoln_MA Friday, December 28, 2018 6:45 PM
    Friday, December 28, 2018 6:41 AM
  • UPDATE:   Hmmm, there's gotta be sumthin' else goin' on.  The Framework HAD been at 3.5. Just downloaded and set the target Framework to 4.7.1 (download was successful).

    That cleared up the ...Tasks reference, but I'm still missing System.Net.Http reference. And what's worse, when I look to see what's available to System.Net, there a buncha options, but "Http" ain't one of'em.

    I am (and was) referencing System.Web but neither that nor System.Threading.Tasks is  referenced (i.e.they're 'grayed out')



    The 'using' statements (and associated code statements) work in a simple console app. What relevant differences exist 'twixt a console app and a WinForm app  ?

    • Edited by Lincoln_MA Friday, December 28, 2018 6:51 PM
    Friday, December 28, 2018 6:46 PM
  • Well, THAT was quite a horror-show, but it does seem to be working now.

    I use the term 'horror-show' cuz it involved getting something from NuGet. That was certainly fun!  But, the good news is that after about three hours, and a lotta searching of the internet (Thank You, Google!), it does seem to be working now … and, in a Winform app.

    T'morra I will move the function to the actual target (to keep things simple, I placed it in a throw-away, test WinApp). I expect that will go smoothly. I think the battle is largely over now. We'll see what happens t'morra.

    So, thank you, Viorel. You got me started on the right path.

    'preciate your help.

    • Marked as answer by Lincoln_MA Saturday, December 29, 2018 2:08 AM
    Saturday, December 29, 2018 2:07 AM