简体   繁体   English

找不到 System.Net.Http.HttpClient class

[英]Can't find System.Net.Http.HttpClient class

I am trying to create HTTP client with PowerShell.我正在尝试使用 PowerShell 创建 HTTP 客户端。
In some places like this and this , it shows that I need to create an object like that:在一些像thisthis的地方,它表明我需要像这样创建一个 object:

$client = [System.Net.Http.HttpClient]::new()

But PowerShell doesn't find any class after System.net.Http.但是 PowerShell 在System.net.Http. . .
In Microsoft it shows that there is a class named HttpClient so I not sure why I can see it with PowerShell.Microsoft中,它显示有一个名为HttpClient的 class,所以我不确定为什么我可以通过 PowerShell 看到它。

I am using PowerShell 5.1.18362.1801.我正在使用 PowerShell 5.1.18362.1801。

Make sure to load the System.Net.Http assembly.确保加载System.Net.Http程序集。

Add-Type -AssemblyName System.Net.Http
$client = [System.Net.Http.HttpClient]::new()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM