System.Net.Http: missing from namespace? (using .net 4.5)

后端 未结 16 2224
我寻月下人不归
我寻月下人不归 2020-11-27 17:57

TL; DR: I\'m new to this language and have no idea what I\'m doing

here is my class so far:

using System;
using System.Collections.Generic;
using Sys         


        
相关标签:
16条回答
  • 2020-11-27 18:28

    You'll need a using System.Net.Http at the top.

    0 讨论(0)
  • You need to have a Reference to the System.Web.Http assembly which has the HTTPClient class, your trying to use. Try adding the below line before your class declaration

    using System.Web.Http;
    

    If you still get the Error, try doing this in Visual Studio

    1. Right click on the References folder on your project.
    2. Select Add Reference.
    3. Select the .NET tab (or select the Browse button if it is not a .NET Framework assembly).
    4. Double-click the assembly containing the namespace in the error message (System.Web.Http.dll).
    5. Press the OK button.
    0 讨论(0)
  • 2020-11-27 18:30

    Making the "Copy Local" property True for the reference did it for me. Expand References, right-click on System.Net.Http and change the value of Copy Local property to True in the properties window. I'm using VS2019.

    0 讨论(0)
  • 2020-11-27 18:33

    Visual Studio Package Manager Console > Install-Package Microsoft.AspNet.WebApi.Client

    0 讨论(0)
提交回复
热议问题