【问题标题】:Azure LogicManagementClient returning "Attempted to access an element as a type incompatible with the array." error during initializationAzure LogicManagementClient 返回“尝试将元素作为与数组不兼容的类型访问。”初始化过程中发生错误
【发布时间】:2022-01-04 09:05:52
【问题描述】:

我正在尝试使用 LogicManagementClient 检索 Azure 逻辑应用操作的执行历史记录,但是得到“尝试将元素作为与数组不兼容的类型进行访问。”下一行的错误-

LogicManagementClient client = new LogicManagementClient(credentials) { SubscriptionId = "****" };

凭据对象已成功创建,我可以在调试时看到值 -

var credentials = SdkContext.AzureCredentialsFactory
                .FromServicePrincipal("clientid",
                    "clientsecret",
                    "tenantid",
                    AzureEnvironment.AzureGlobalCloud);

下面是堆栈跟踪 -

System.ArrayTypeMismatchException
  HResult=0x80131503
  Message=Attempted to access an element as a type incompatible with the array.
  Source=mscorlib
  StackTrace:
   at System.Collections.Generic.List`1.Add(T item)
   at Microsoft.Azure.Management.Logic.LogicManagementClient.Initialize()
   at Microsoft.Azure.Management.Logic.LogicManagementClient..ctor(ServiceClientCredentials credentials, DelegatingHandler[] handlers)

感谢任何解决此问题的建议。谢谢!

【问题讨论】:

    标签: c# azure azure-logic-apps


    【解决方案1】:

    我能够通过在引用前面提到的代码的项目的 app.config 文件中添加以下内容来解决此问题 -

    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <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>
    </assemblyBinding>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-03-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多