How to add/use C# libraries in JetBrains Rider?
Asked Answered
H

1

6

I am trying to use HttpClient client however I am unable to use using System.Net.Http;. How to correctly use C# libraries in JetBrains Rider?

enter image description here

The os is linux.

Heraldry answered 22/5, 2018 at 0:37 Comment(3)
Google "jetbrains rider add reference" > "For now there are only one way to edit them - editing *.csproj file."Lorola
@CamiloTerevinto This is no longer accurate with current releases of Rider.Artifice
as a little side note, using doesn't import a library. It's purely a namespace thing. It's like saying "everything in this namespace I want to use as if it was in the global namespace". It means you don't need to fully qualify everything.Suppurative
A
5

System.Net.Http is not a standard reference included with console applications. You will need to add the reference explicitly to use it.

You can do this in Rider by right clicking the project in question, selecting Add > Add Reference. This will pop a dialog that will populate the system references. Once populated, find System.Net.Http and select it. Confirm the dialog. Your using should now work as expected.

Tested with Rider 2018.1 on windows.

Artifice answered 22/5, 2018 at 1:3 Comment(3)
What if it doesn't? Where are those System libraries actually located? My rider populates this dialog with my project's internalsBlithering
@Blithering If you can't reference it as a system library, I would recommend you add the System.Net.Http NuGet package instead of attempting to path to it directly, as that is likely to break the project in other people's environments.Artifice
Thanks! I'll try thatBlithering

© 2022 - 2024 — McMap. All rights reserved.