我遇到了一些非常奇怪的问题。所有最新的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控制台应用程序。除此之外的一切都很好。
这里的问题的截图:
我发现这个开发商,类似的问题而回,但没有涉及到PowerBI。但是没有答案。
Adding Iso8601TimeSpanConverter to JsonConverter list throws ArrayTypeMismatch exception