由于 Watson 的包问题而引发的异常

我想在 Visual Studio 2015 中创建一个使用 IBM 的 Watson Assistant SDK 的 C# 应用程序,有关它的信息可以在这里找到。但是,当我去运行我的代码并初始化 的实例时AssistantService,它会抛出这个 System.Security.VerificationException,弹出窗口突出显示正在调用的构造函数,上面写着

System.Net.Http.Formatting.dll 中出现类型为“System.Security.VerificationException”的异常,但未在用户代码中处理附加信息:方法 System.Net.Http.CloneableExtensions.Clone:类型参数“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!");                 

        }

    }

}


紫衣仙女
浏览 187回答 1
1回答

叮当猫咪

我想报告此事。我能够通过将所有包更新到当前版本来解决我的问题,因为由于某些依赖冲突,它不允许我更新 System.Net.Http。之后,我将 System.IO.Compression 恢复到 4.1.0 版,这又是由于依赖关系将 NETStandard.Library 恢复到 1.6.0 版。现在一切正常,希望这可以帮助其他人处理此类事情。
打开App,查看更多内容
随时随地看视频慕课网APP