gpt4 book ai didi

c# - 简单 WebClient 仅按名称不工作 : Customized cultures cannot be passed by LCID,

转载 作者:太空宇宙 更新时间:2023-11-03 12:51:46 25 4
gpt4 key购买 nike

我正在尝试使用 WebClient 向 URL 发送一个简单的 POST 请求,但我收到了

An exception occurred during a WebClient request.

在 InnerException 中

Customized cultures cannot be passed by LCID, only by name.

显然互联网上没有关于此异常的讨论。

这是我的代码:

public static void Send(string message)
{
var url = "https://api.mailgun.net/v3/sandbox1ebb54bdb39044988d3c916d833769b7.mailgun.org/messages";
using (var client = new WebClient())
{
client.Credentials = new NetworkCredential("api", "some_password");
var values = new NameValueCollection();
values["from"] = "Mailgun Sandbox <postmaster@sandbox1ebb54bdb39044988d3c916d833769b7.mailgun.org>";
var response = client.UploadValues(url, values);
var responseString = Encoding.Default.GetString(response);
Reader.log(responseString);
}
}

client.UploadValues(url, values) 处引发异常

最佳答案

显然,这是旧版本 .NET 的一个已知问题(如果您的系统区域设置不是美国)https://connect.microsoft.com/VisualStudio/feedback/details/1741767/compiler-error-customized-cultures-cannot-be-passed-by-lcid-only-by-name

迁移到 .NET 4.0 或更高版本可以解决问题。

关于c# - 简单 WebClient 仅按名称不工作 : Customized cultures cannot be passed by LCID,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35266740/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com