title: PowerBIClient generates System.ArrayTypeMismatchException under certain circumstances
body: <p>I have some really strange issue going on. With all the latest PowerBI nuget-packages and their latest iterations of dependencies I get the following exception:</p>
  
  <pre><code>Exception thrown: 'System.ArrayTypeMismatchException' in mscorlib.dll
  
  Additional information: Attempted to access an element as a type incompatible with the array.
  </code></pre>
  
  <p>The stack trace shows me this:</p>
  
  <pre><code>   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
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>/// &lt;/summary&gt;
  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&lt;JsonConverter&gt;
              {
                  new Iso8601TimeSpanConverter()
              }
      };
      DeserializationSettings = new JsonSerializerSettings
      {
          DateFormatHandling = DateFormatHandling.IsoDateFormat,
          DateTimeZoneHandling = DateTimeZoneHandling.Utc,
          NullValueHandling = NullValueHandling.Ignore,
          ReferenceLoopHandling = ReferenceLoopHandling.Serialize,
          ContractResolver = new ReadOnlyJsonContractResolver(),
          Converters = new List&lt;JsonConverter&gt;
              {
                  new Iso8601TimeSpanConverter()
              }
      };
      CustomInitialize();
  }
  </code></pre>
  
  <p>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.</p>
  
  <p>Here's the screenshot of the problem:</p>
  
  <p><a href="https://i.stack.imgur.com/LrPfw.png" rel="nofollow noreferrer">Screenshot of the issue</a></p>
  
  <p>I found this developer with a similar issue a while back but not related to PowerBI. No answer however.</p>
  
  <p><a href="https://stackoverflow.com/questions/39339605/adding-iso8601timespanconverter-to-jsonconverter-list-throws-arraytypemismatch-e">Adding Iso8601TimeSpanConverter to JsonConverter list throws ArrayTypeMismatch exception</a></p>