2017-02-22 143 views
0

我遇到了一些非常奇怪的問題。所有最新的PowerBI的NuGet的程序包和他們最新的依賴,我得到以下異常迭代:PowerBIClient在某些情況下生成System.ArrayTypeMismatchException

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

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

堆棧跟蹤顯示我:

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 

雖然試圖尋找到PowerBIClient源代碼我在初始化發現,它試圖類類型Iso8601TimeSpanConverter的添加到列表JsonConvert,只要看看這裏:

/// </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(); 
} 

我不能figu回顧一下爲什麼在我的應用程序中發生這種情況,而在後面幾個版本的演示示例中,它完全正常工作。但是我確實知道,當我最初使用4.6.1中的常規.NET控制檯應用程序時,我也有它的工作。但是現在我正在使用.NET 4.6.1框架使用.NET Core控制檯應用程序。除此之外的一切都很好。

這裏的問題的截圖:

Screenshot of the issue

我發現這個開發商,類似的問題而回,但沒有涉及到PowerBI。但是沒有答案。

Adding Iso8601TimeSpanConverter to JsonConverter list throws ArrayTypeMismatch exception

回答

0

鏈接到你現在所提供的問題中包含一個暗示,幫我解決這個問題。在我的情況下,它是由GAC中安裝的多個版本的Newtonsoft.Json.dll引起的。在配置我的應用程序以解決對最新版本的庫引用後,異常消失。