Azure LogicManagementClient returning "Attempted to access an element as a type incompatible with the array." error during initialization

mitesh patel 6 Reputation points
2022-01-04T09:10:49.467+00:00

I'm trying to retrieve the Azure logic app actions' execution history using LogicManagementClient however getting 'Attempted to access an element as a type incompatible with the array.' error at below line -

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

The credentials object is created successfully and I could see the values while debugging -

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

Below is the stack trace -

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)

Appreciate any suggestions to overcome the issue. Thanks!

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,542 questions
Developer technologies C#
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. MayankBargali-MSFT 70,936 Reputation points Moderator
    2022-01-04T11:19:23.3+00:00

    @mitesh patel Can you please confirm the version for Microsoft.Azure.Management.Logic and Microsoft.Azure.Management.ResourceManager.Fluent that you are using in your project? If you are not using the latest version then I will suggest updating to the latest version and see if it helps you to resolve the issue.
    I couldn't reproduce the issue at my end and I am using the current latest version from NuGet i.e. Microsoft.Azure.Management.ResourceManager.Fluent (1.38.0) and Microsoft.Azure.Management.Logic (4.1.0).

    162194-image.png

    0 comments No comments

  2. mitesh patel 6 Reputation points
    2022-01-05T07:33:45.62+00:00

    Thanks @MayankBargali-MSFT for your reply! Yes, I'm using latest version for both the NuGet packages. I was able to fix the issue by adding below in the app.config file in the project that was referencing the earlier mentioned code -

    <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>


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.