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-throws-arraytypemismatch-e