Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio 无法加载文件或程序集,系统找不到指定的文件_Visual Studio_Json.net_Nuget_Azure Functions_Alexa Skills Kit - Fatal编程技术网

Visual studio 无法加载文件或程序集,系统找不到指定的文件

Visual studio 无法加载文件或程序集,系统找不到指定的文件,visual-studio,json.net,nuget,azure-functions,alexa-skills-kit,Visual Studio,Json.net,Nuget,Azure Functions,Alexa Skills Kit,我正在创建一个Azure函数作为Alexa技能的后端 到目前为止,我在Visual Studio中所做的一切: 文件->新建Azure功能项目 添加新的Azure函数 使用NuGet添加AlexaSkillsKit.NET 创建Speechlet实现的shell 向Azure函数添加最小代码以处理speechlet 编译时,我得到一个错误: 无法加载文件或程序集'Newtonsoft.Json,版本=7.0.0.0, 文化=中性,PublicKeyToken=30AD4FE6B2A6EED'或其

我正在创建一个Azure函数作为Alexa技能的后端

到目前为止,我在Visual Studio中所做的一切:

  • 文件->新建Azure功能项目
  • 添加新的Azure函数
  • 使用NuGet添加AlexaSkillsKit.NET
  • 创建
    Speechlet
    实现的shell
  • 向Azure函数添加最小代码以处理speechlet
  • 编译时,我得到一个错误:

    无法加载文件或程序集'Newtonsoft.Json,版本=7.0.0.0, 文化=中性,PublicKeyToken=30AD4FE6B2A6EED'或其 依赖关系。系统找不到指定的文件

    但是根据VisualStudio中的NuGet,它并没有试图使用7.0.0.0,而是使用了9+。我尝试过更新和降级JSON.net包。我尝试过从零开始清理/重建/重新启动

    我认为也许汇编绑定可能是答案,但Azure功能项目中没有Web.config或App.config

    我错过了什么?我如何消除这个错误

    演讲稿代码:

    public class MySpeechlet : SpeechletBase, ISpeechletWithContextAsync
    {
        public Task<SpeechletResponse> OnIntentAsync(IntentRequest intentRequest, Session session, Context context)
        {
            throw new System.NotImplementedException();
        }
    
        public Task<SpeechletResponse> OnLaunchAsync(LaunchRequest launchRequest, Session session, Context context)
        {
            throw new System.NotImplementedException();
        }
    
        public Task OnSessionStartedAsync(SessionStartedRequest sessionStartedRequest, Session session, Context context)
        {
            throw new System.NotImplementedException();
        }
    
        public Task OnSessionEndedAsync(SessionEndedRequest sessionEndedRequest, Session session, Context context)
        {
            throw new System.NotImplementedException();
        }
    }
    
    公共类MySpeechlet:SpeechletBase,ISpeechletWithContextAsync
    {
    公共任务OnIntentAsync(IntentRequest IntentRequest、会话会话、上下文)
    {
    抛出新系统。NotImplementedException();
    }
    公共任务OnLaunchAsync(LaunchRequest LaunchRequest、会话会话、上下文)
    {
    抛出新系统。NotImplementedException();
    }
    公共任务OnSessionStartedAsync(SessionStartedRequest SessionStartedRequest,会话会话,上下文)
    {
    抛出新系统。NotImplementedException();
    }
    公共任务OnSessionEndedAsync(SessionEndRequest SessionEndRequest、会话会话、上下文)
    {
    抛出新系统。NotImplementedException();
    }
    }
    
    Azure功能:

    public static class MyFunction
    {
        [FunctionName("MyFunction")]
        public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)]HttpRequestMessage req, TraceWriter log)
        {
            var speechlet = new MySpeechlet();
            return await speechlet.GetResponseAsync(req);
        }
    }
    
    公共静态类MyFunction
    {
    [函数名(“MyFunction”)]
    公共静态异步任务运行([HttpTrigger(AuthorizationLevel.Anonymous,“get”,“post”,Route=null)]HttpRequestMessage请求,TraceWriter日志)
    {
    var speechlet=new MySpeechlet();
    返回wait speechlet.GetResponseAsync(req);
    }
    }
    
    Azure Function 1.X主机本身依赖于Newtonsoft.Json 9:

    这是将要加载的DLL,这是azure函数中已知且非常恼人的问题:

    如果Alexaskills特别依赖于7,并且不能与9一起工作,那么我担心您会被卡住,可能会在Alexaskills上创建一个pull请求


    作为旁注,如果您使用最新工具创建了Azure函数,那么您的项目应该对Microsoft.NET.Sdk.Functions具有依赖关系,这至少使这些依赖关系变得明确

    您的一个依赖项是否将Newton v7作为子依赖项?不,这就是我所说的“根据Visual Studio中的NuGet,它不尝试使用7.0.0.0,而是使用9+”。但假设是这样的话,我能做些什么呢?嗨@MatthewGroves看起来问题出在Alexaskills软件包上。如果我们使用1.5.2版,我就能够构建解决方案。如果使用1.6.0版本,则会引发错误。看起来v7依赖项是从Alexaskills包中获得的。刚从最新的代码中做了一个分支。Alexaskills软件包有一个依赖项
    Newtonsoft.Json(>=7.0.1)
    ,您是否在项目中引用了另一个版本nuget Newtonsoft.Json 9.0+?如果是,用7.0.1版替换它怎么样?