2017-02-22 195 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引起的。在配置我的应用程序以解决对最新版本的库引用后,异常消失。

相关问题