Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
novak
Regular Visitor

PowerBIClient generates System.ArrayTypeMismatchException

Hey fellas!

 

I have som really strange issue going on. With all the latest PowerBI nuget-packages and their latest iterations of dependencies I get the following exception:

 

 

Exception thrown: 'System.ArrayTypeMismatchException' in mscorlib.dll

Additional information: Attempted to access an element as a type incompatible with the array.

 

 

The stack trace shows me this:

 

 

   at System.Collections.Generic.List`1.Add(T item)
   at Microsoft.PowerBI.Api.V1.PowerBIClient.Initialize()
   at Microsoft.PowerBI.Api.V1.PowerBIClient..ctor(ServiceClientCredentials credentials, DelegatingHandler[] handlers)
   at Apps.Kinetic.Reports.Endpoint.Service.Reports.g1u0.GenerateAccessToken(String _Reference) in D:\*masked*.cs:line 575

 

 

While trying to look into the PowerBIClient source code I found on Initialize that it does attempt to add a class of type Iso8601TimeSpanConverter to a JsonConvert list, just have a look here:

 

 

        /// </summary>
        private void Initialize()
        {
            this.Datasets = new Datasets(this);
            this.Gateways = new Gateways(this);
            this.Imports = new Imports(this);
            this.Workspaces = new Workspaces(this);
            this.Reports = new Reports(this);
            this.BaseUri = new Uri("https://api.powerbi.com");
            SerializationSettings = new JsonSerializerSettings
            {
                Formatting = Formatting.Indented,
                DateFormatHandling = DateFormatHandling.IsoDateFormat,
                DateTimeZoneHandling = DateTimeZoneHandling.Utc,
                NullValueHandling = NullValueHandling.Ignore,
                ReferenceLoopHandling = ReferenceLoopHandling.Serialize,
                ContractResolver = new ReadOnlyJsonContractResolver(),
                Converters = new List<JsonConverter>
                    {
                        new Iso8601TimeSpanConverter()
                    }
            };
            DeserializationSettings = new JsonSerializerSettings
            {
                DateFormatHandling = DateFormatHandling.IsoDateFormat,
                DateTimeZoneHandling = DateTimeZoneHandling.Utc,
                NullValueHandling = NullValueHandling.Ignore,
                ReferenceLoopHandling = ReferenceLoopHandling.Serialize,
                ContractResolver = new ReadOnlyJsonContractResolver(),
                Converters = new List<JsonConverter>
                    {
                        new Iso8601TimeSpanConverter()
                    }
            };
            CustomInitialize();
        }

 

 

Now for the love of I god I can't figure out why this is occurring in my application while in the demo sample with a few versions behind, has it fully working. But I do know that I also had it working when I at first used a regular .NET console app in 4.6.1. But now I'm using a .NET Core console app using the .NET 4.6.1 framework. Everything but this works just fine.

Here's the screenshot of the problem:

 

 

Please advice! Thanks in advance!

 

Update: I found this fella with a similiar issue a while back but not related to PowerBI. No answer however. 😞

http://stackoverflow.com/questions/39339605/adding-iso8601timespanconverter-to-jsonconverter-list-th...

2 REPLIES 2
Eric_Zhang
Microsoft Employee
Microsoft Employee

@novak

Not yet reproduce that exception at this moment, and I'll research on this.

Meanwhile, an issue request is raised in the github lib, we could wait for the author's reponse at the same time.

I'm sorry, at this time there's no acceptable solution to this issue so I went ahead and rebuilt the whole thing using REST calls. Too bad it had to cost me loads of hours to resolve with a complete workaround.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.