AutoRest自动生成的代码未初始化

时间:2019-01-02 10:23:30

标签: azure autorest

我有一个Azure函数应用程序,它正在使用由AutoRest(0.17.3)创建的自动生成的客户端。当功能应用调用自动生成代码的initialize方法时,将引发以下错误,

Microsoft.Azure.WebJobs.Script: One or more errors occurred. mscorlib: Attempted to access an element as a type incompatible with the array.

将Iso8601TimeSpanConverter作为转换器添加到JsonSerializerSettings时发生错误

SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings
        {
            Formatting = Newtonsoft.Json.Formatting.Indented,
            DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
            DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc,
            NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore,
            ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
            ContractResolver = new Microsoft.Rest.Serialization.ReadOnlyJsonContractResolver(),
            Converters = new  System.Collections.Generic.List<Newtonsoft.Json.JsonConverter>
                {
                    new Microsoft.Rest.Serialization.Iso8601TimeSpanConverter()
                }
        };

我的newtonsoft.json的app.config设置是

<dependentAssembly>
    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
  </dependentAssembly>

从控制台应用程序无法再现此问题,但是在Azure功能应用程序上部署时会发生此问题。

0 个答案:

没有答案