1. <tfoot id='5Iq0O'></tfoot>

    <legend id='5Iq0O'><style id='5Iq0O'><dir id='5Iq0O'><q id='5Iq0O'></q></dir></style></legend>

    <small id='5Iq0O'></small><noframes id='5Iq0O'>

    <i id='5Iq0O'><tr id='5Iq0O'><dt id='5Iq0O'><q id='5Iq0O'><span id='5Iq0O'><b id='5Iq0O'><form id='5Iq0O'><ins id='5Iq0O'></ins><ul id='5Iq0O'></ul><sub id='5Iq0O'></sub></form><legend id='5Iq0O'></legend><bdo id='5Iq0O'><pre id='5Iq0O'><center id='5Iq0O'></center></pre></bdo></b><th id='5Iq0O'></th></span></q></dt></tr></i><div id='5Iq0O'><tfoot id='5Iq0O'></tfoot><dl id='5Iq0O'><fieldset id='5Iq0O'></fieldset></dl></div>
        <bdo id='5Iq0O'></bdo><ul id='5Iq0O'></ul>

      Newtonsoft.Json 参考抱怨 Azure Functions

      Newtonsoft.Json reference complaining on Azure Functions(Newtonsoft.Json 参考抱怨 Azure Functions)

        <tbody id='vIwTH'></tbody>
      <tfoot id='vIwTH'></tfoot>
      1. <small id='vIwTH'></small><noframes id='vIwTH'>

          <legend id='vIwTH'><style id='vIwTH'><dir id='vIwTH'><q id='vIwTH'></q></dir></style></legend>

            <i id='vIwTH'><tr id='vIwTH'><dt id='vIwTH'><q id='vIwTH'><span id='vIwTH'><b id='vIwTH'><form id='vIwTH'><ins id='vIwTH'></ins><ul id='vIwTH'></ul><sub id='vIwTH'></sub></form><legend id='vIwTH'></legend><bdo id='vIwTH'><pre id='vIwTH'><center id='vIwTH'></center></pre></bdo></b><th id='vIwTH'></th></span></q></dt></tr></i><div id='vIwTH'><tfoot id='vIwTH'></tfoot><dl id='vIwTH'><fieldset id='vIwTH'></fieldset></dl></div>
                <bdo id='vIwTH'></bdo><ul id='vIwTH'></ul>

              • 本文介绍了Newtonsoft.Json 参考抱怨 Azure Functions的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在运行一个名为 SmsWebhook 的 Azure Functions.它调用外部程序集 AzureFunctionsSample.Services.dll 中的一个方法,该方法引用了 Newtonsoft.Json 8.0.3

                I'm running an Azure Functions, called SmsWebhook. It calls a method in an external assembly, AzureFunctionsSample.Services.dll that has a reference to Newtonsoft.Json 8.0.3

                我的 Run.csx 的详细信息如下:

                The details of my Run.csx looks like:

                #r "AzureFunctionsSample.Services.dll"
                using System.Net;
                using AzureFunctionsSample.Services
                
                public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)
                {
                    ...
                }
                

                在上面的Run()方法中,我创建了一个实例,并在实例中调用了一个方法.但是,每当我调用该方法时,都会收到以下错误:

                Within the Run() method above, I create an instance and call a method in the instance. However, whenever I call that method, I receive the following error:

                2016-05-19T13:41:45  Welcome, you are now connected to log-streaming service.
                2016-05-19T13:41:46.878 Function started (Id=64fccf0c-d0ef-45ef-ac1c-7736adc94566)
                2016-05-19T13:41:46.878 C# HTTP trigger function processed a request. RequestUri=https://ase-dev-fn-demo.azurewebsites.net/api/smswebhook
                2016-05-19T13:41:46.878 Function completed (Failure, Id=64fccf0c-d0ef-45ef-ac1c-7736adc94566)
                2016-05-19T13:41:46.894 Exception while executing function: Functions.SmsWebhook. Microsoft.Azure.WebJobs.Script: One or more errors occurred. AzureFunctionsSample.Services: Could not load file or assembly 'Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040).
                

                我在bin目录下手动添加了相同版本的Newtonsoft.Json.dll,但还是报同样的错误.为什么它在 Newtonsoft.Json.dll 文件中抱怨?

                I manually added the same version of Newtonsoft.Json.dll under the bin directory, but still got the same error. Why is it complaining at the Newtonsoft.Json.dll file?

                如果我将外部程序集中的所有逻辑都移到 Run.csx 中,顺便说一句,它不会抱怨.

                If I move all the logics within the external assembly into the Run.csx, it won't complain, by the way.

                推荐答案

                @JustInChronicles,我在这里添加这个作为参考的答案,但预期的行为应该是私有程序集的间接依赖关系是从你的 bin 文件夹,如预期的那样.

                @JustInChronicles, I'm adding this here as an answer for reference, but the expected behavior should be that indirect dependencies of private assemblies are resolved from your bin folder, as expected.

                我汇总了以下测试来重现您的场景:

                I put together the following test to reproduce your scenario:

                • 创建了一个简单类型的简单类库,该类库使用 Json.NET 序列化对象并返回 JSON 字符串.此程序集引用 Json.NET 8.0.3.结果包括它正在使用的 Json.NET 程序集版本
                • 创建了一个函数,该函数使用 #r "DependencyWithJsonRef.dll" 引用该类型 only,并返回上述方法产生的结果
                • DependencyWithJsonRef.dllNewtonsoft.Json.dll (8.0.3) 部署到我的函数的 bin 文件夹
                • Created a simple class library with a simple type that uses Json.NET to serialize an object and return the JSON string. This assembly references Json.NET 8.0.3. The result includes the Json.NET assembly version it is using
                • Created a function that references that type only with a #r "DependencyWithJsonRef.dll" and returns the result produced by the method mentioned above
                • Deployed DependencyWithJsonRef.dll and Newtonsoft.Json.dll (8.0.3) to my function's bin folder

                调用函数会产生预期的结果.

                Invoking the function produces the expected result.

                这里是函数,供参考:

                #r "DependencyWithJsonRef.dll"
                
                using System.Net;
                
                public static string Run(HttpRequestMessage req, TraceWriter log)
                {
                    var myType = new DependencyWithJsonRef.TestType();
                    return myType.GetFromJson();
                }
                

                如您所见,不需要显式引用间接依赖项 (Json.NET).

                As you can see, no explicit reference to indirect dependencies (Json.NET) required.

                这是我得到的输出:

                {
                    "Prop1":"Test",
                    "Prop2":1,
                    "AssemblyName": "Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed"
                }
                

                快速说明:您可能需要检查一件事,特别是如果您在开发函数时更新了该依赖项,即没有缓存程序集结果结果.确保您从零开始的一个可靠方法是(在部署函数和程序集之后)转到 Kudu 并终止 non-scm w3wp 进程,看看是否有帮助.我很想知道这是否有效,因为如果有效,我们可以采取一些措施来改进它.

                Quick note: One thing you may want to check, particularly if you've updated that dependency while developing your function is that assembly resultion results were not cached. A sure way to make sure you're starting with a clean slate is to (after you deploy your function and assemblies) go to Kudu and kill the non-scm w3wp process to see if that helps. I'd be curious to know if that does the trick as there are a few things we can to to improve this if it does.

                这篇关于Newtonsoft.Json 参考抱怨 Azure Functions的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Adding and removing users from Active Directory groups in .NET(在 .NET 中的 Active Directory 组中添加和删除用户)
                set equality in linq(在 linq 中设置相等)
                HashSet conversion to List(HashSet 转换为 List)
                How to set timeout for webBrowser navigate event(如何为 webBrowser 导航事件设置超时)
                Test whether two IEnumerablelt;Tgt; have the same values with the same frequencies(测试两个IEnumerablelt;Tgt;具有相同频率的相同值)
                How do you determine if two HashSets are equal (by value, not by reference)?(您如何确定两个 HashSet 是否相等(按值,而不是按引用)?)
              • <legend id='xuwYM'><style id='xuwYM'><dir id='xuwYM'><q id='xuwYM'></q></dir></style></legend>
              • <tfoot id='xuwYM'></tfoot>

                  <small id='xuwYM'></small><noframes id='xuwYM'>

                    <bdo id='xuwYM'></bdo><ul id='xuwYM'></ul>
                      <tbody id='xuwYM'></tbody>

                    <i id='xuwYM'><tr id='xuwYM'><dt id='xuwYM'><q id='xuwYM'><span id='xuwYM'><b id='xuwYM'><form id='xuwYM'><ins id='xuwYM'></ins><ul id='xuwYM'></ul><sub id='xuwYM'></sub></form><legend id='xuwYM'></legend><bdo id='xuwYM'><pre id='xuwYM'><center id='xuwYM'></center></pre></bdo></b><th id='xuwYM'></th></span></q></dt></tr></i><div id='xuwYM'><tfoot id='xuwYM'></tfoot><dl id='xuwYM'><fieldset id='xuwYM'></fieldset></dl></div>