我想在Visual Studio 2015中使用IBM的Watson Assistant SDK创建一个C#应用程序,该SDK上有可以找到它的信息here。但是,当我运行我的代码并初始化AssistantService
的实例时,它会抛出此System.Security.VerificationException,并弹出一个窗口,突出显示正在调用的构造函数
发生了'System.Security.VerificationException'类型的异常 在System.Net.Http.Formatting.dll中但未在用户代码中处理 附加信息:方法 System.Net.Http.CloneableExtensions.Clone:type参数 'System.Net.Http.Headers.MediaTypeHeaderValue'违反了约束 类型参数'T'。
我做了一些研究,显然知道这个问题与System.Net.Http
包有关,我根据前一个帖子中的建议恢复到版本4.0.0,但无济于事。我可以提供有关我的设置,代码和错误的更多信息,如果它有用的话。提前感谢任何人能够提供的建议。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using IBM.WatsonDeveloperCloud.Assistant.v1;
namespace Watson_Test
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
AssistantService _assistant;
public MainWindow()
{
InitializeComponent();
_assistant = new AssistantService();
Console.WriteLine("Success!");
}
}
}
这是我程序输出的全部link。
答案 0 :(得分:1)
我想报告这个。我能够通过将所有软件包更新到当前版本来解决我的问题,因为由于某些依赖性冲突,它不允许我更新System.Net.Http。之后,我将System.IO.Compression还原为版本4.1.0,将.NETStandard.Library还原为版本1.6.0,再次归因于依赖性。
现在一切正常,希望这有助于其他人从事这类工作。