c# - IBM WATSON TEXT TO SPEECH ERROR : : 请求被中止:无法创建 SSL/TLS 安全通道
问题描述
今天我在我的 C# WPF 应用程序中使用了 ibm 云服务,它是 ibm watson 文本到语音,但是当我执行我的方法时,它显示一个异常,即请求被中止:无法创建 SSL/TLS 安全通道。
我的方法是
void Example()
{
IamAuthenticator authenticator = new IamAuthenticator(apikey: "{APIKEY}");
TextToSpeechService textToSpeech = new TextToSpeechService(authenticator);
textToSpeech.SetServiceUrl("URL");
var result = textToSpeech.ListVoices();
MessageBox.Show(result.Result.ToString());
}
我不知道下一步该怎么做..因为我陷入了这个异常
解决方案
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
在静态块中使用这行代码,如构造函数和
static System.Net.SecurityProtocolType SecurityProtocol
{
get;
set;
}
使用这种静态方法。
推荐阅读
- c# - 如果字典使用 LINQ,如何打印空值
- python - 如何在python的内存中映射/加载文件并从另一个进程访问它?
- ruby-on-rails - 未找到 Rails 6 活动存储附件 404
- c++ - 为什么使用 execution::par 对向量进行排序比普通排序(gcc 10.1.0)花费更长的时间?
- heroku - Heroku 不会在 Visual Studio Code 中加载
- asp.net-core - 带有 GetView 的 IrazorViewEngine.FindView 找不到视图
- google-apps-script - DriveApp.setSharing 现在抛出异常,遗留运行时有问题吗?
- javascript - DyanmoDB getItem 未在 Async Lambda 中提供任何响应
- regex - 正则表达式捕获除最后一个主题标签之外的所有内容
- python - 如何创建自定义标签以在命令行中获取输入字符串并将它们存储在 Python 中的变量中