gpt4 book ai didi

c# - Azure LogicManagementClient 在初始化期间返回 "Attempted to access an element as a type incompatible with the array."错误

转载 作者:行者123 更新时间:2023-12-03 07:10:17 26 4
gpt4 key购买 nike

我尝试使用 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)

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

最佳答案

我能够通过在引用前面提到的代码的项目中的 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>

关于c# - Azure LogicManagementClient 在初始化期间返回 "Attempted to access an element as a type incompatible with the array."错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70576359/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com