23

I am trying to use the Dropbox.API code that is listed here:

https://github.com/dropbox/dropbox-sdk-dotnet/tree/master/dropbox-sdk-dotnet/Examples/SimpleTest

I copied their Program.cs into my Program.cs without making other changes to other files in my solution/project.

I am getting

The type or namespace name "WebRequestHandler" could not be found.

enter image description here

Despite having this using statement:

using System.Net.Http;

The help text says to add an assembly reference, but I don't know what I would add.

I tried moving the using System.Net.Http to both inside and outside the class.

I am new to C# and .Net development so expect this to be a really newbie problem.

Be Kind To New Users
  • 9,672
  • 13
  • 78
  • 125

2 Answers2

36

Have you included a reference to the System.Net.Http.WebRequest DLL? This is where the WebRequestHandler is found, not in System.Net.Http.

See this article on MSDN.

In short, you can add the reference to System.Net.Http.WebRequest DLL by right clicking on the project and doing Add -> Reference. Expect a popup window to appear and then put a checkmark next to System.Net.Http.WebRequest.

Be Kind To New Users
  • 9,672
  • 13
  • 78
  • 125
GrandMasterFlush
  • 6,269
  • 19
  • 81
  • 104
  • in VS2017 programming for a .NET 4.0 targeted version, I had to run VS Installer, Change, add ASP.NET MVC4 because apparently, the dll for the System.Net.Http... namespaces is contained there. – Cee McSharpface Dec 23 '19 at 17:31
6

I can confirm this lunacy:) You can pull System.Net.Http via NuGet but not System.Net.Http.WebRequest:) System.Net.Http.WebRequest is to be referenced via "Add Reference".

LilleElefant
  • 422
  • 1
  • 5
  • 14