【问题标题】:Exceptions when calling Kusto API in Android environment在 Android 环境中调用 Kusto API 时出现异常
【发布时间】:2021-02-02 02:27:41
【问题描述】:

我正在开发一个 Xamarin 移动应用程序,该应用程序查询 ADX 集群中的一些数据。我已经使用 Kusto SDK 设置了一个项目,并且正在使用教程代码 here 进行测试:

var client = Kusto.Data.Net.Client.KustoClientFactory.CreateCslQueryProvider("https://help.kusto.windows.net/Samples;Fed=true");
var reader = client.ExecuteQuery("StormEvents | count");

我正在针对 Visual Studio 的 android 模拟器(Pixel 2 Pie 9.0 - API 28)进行测试,发现在执行上面的第一行时会发生以下异常:

System.TypeInitializationException: The type initializer for 'Kusto.Cloud.Platform.Utils.Anchor' threw an exception. ---> System.IO.IOException: Function not implemented
  at System.IO.FileSystemWatcher.StartRaisingEvents () [0x0008e] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.Linux.cs:65 
  at System.IO.FileSystemWatcher.StartRaisingEventsIfNotDisposed () [0x00019] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.cs:664 
  at System.IO.FileSystemWatcher.set_EnableRaisingEvents (System.Boolean value) [0x0001d] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.cs:163 
  at (wrapper remoting-invoke-with-check) System.IO.FileSystemWatcher.set_EnableRaisingEvents(bool)
  at Kusto.Cloud.Platform.Utils.AppSettingsFileProvider.StartWatching () [0x00024] in <108421866c7741bda55f6c9b7c9a34e6>:0 
  at Kusto.Cloud.Platform.Utils.Tweaks.TryRegisterTweaksFile (System.String path, System.String file) [0x000a3] in <108421866c7741bda55f6c9b7c9a34e6>:0 
  at Kusto.Cloud.Platform.Utils.Tweaks.RegisterMandatoryTweaksFiles () [0x00050] in <108421866c7741bda55f6c9b7c9a34e6>:0 
  at Kusto.Cloud.Platform.Utils.Tweaks..ctor () [0x00059] in <108421866c7741bda55f6c9b7c9a34e6>:0 
  at Kusto.Cloud.Platform.Utils.Anchor..cctor () [0x00000] in <108421866c7741bda55f6c9b7c9a34e6>:0 

documentation 似乎表明此代码涉及客户端跟踪,因此我决定使用它提供的代码禁用它:

Kusto.Cloud.Platform.Utils.TraceSourceManager.SetTraceVerbosityForAll(
    Kusto.Cloud.Platform.Utils.TraceVerbosity.Fatal
    );

现在代码产生了不同的错误:

mono_native_thread_id_get assembly:<unknown assembly> type:<unknown type> member:(null)
  at (wrapper managed-to-native) Kusto.Cloud.Platform.Utils.CurrentThread.GetMonoThreadId()
  at Kusto.Cloud.Platform.Utils.CurrentThread.get_NativeThreadId () [0x00033] in <9dd19f80b3864692b4a926469c23a2c0>:0 
  at Kusto.Cloud.Platform.Utils.CreationContext..ctor (System.Boolean deserializing, System.Boolean captureCallStack) [0x0004c] in <9dd19f80b3864692b4a926469c23a2c0>:0 
  at Kusto.Cloud.Platform.Utils.CreationContext..ctor (System.Boolean deserializing) [0x00000] in <9dd19f80b3864692b4a926469c23a2c0>:0 
  at Kusto.Cloud.Platform.Utils.CreationContext..ctor () [0x00000] in <9dd19f80b3864692b4a926469c23a2c0>:0 
  at Kusto.Cloud.Platform.Utils.UtilsKeyNotFoundException.Construct_ExceptionCreationContext (System.Boolean deserializing) [0x0000b] in <9dd19f80b3864692b4a926469c23a2c0>:0 
  at Kusto.Cloud.Platform.Utils.UtilsKeyNotFoundException.Construct (System.Boolean deserializing, System.Nullable`1[T] failureCode, System.String failureSubCode, System.Nullable`1[T] isPermanent) [0x00049] in <9dd19f80b3864692b4a926469c23a2c0>:0 
  at Kusto.Cloud.Platform.Utils.UtilsKeyNotFoundException..ctor (System.String keyValue, System.String keyType, System.String collection, System.Nullable`1[T] failureCode, System.String failureSubCode, System.Nullable`1[T] isPermanent) [0x0001b] in <9dd19f80b3864692b4a926469c23a2c0>:0 
  at Kusto.Data.KustoConnectionStringValidator.IsValid (Kusto.Data.KustoConnectionStringBuilder kcsb, System.String& errorMessage) [0x001fd] in <e31358719a0646d580915bb27daf320c>:0 
  at Kusto.Data.KustoConnectionStringValidator.ValidateProperties (Kusto.Data.KustoConnectionStringBuilder kcsb) [0x00000] in <e31358719a0646d580915bb27daf320c>:0 
  at Kusto.Data.Net.Client.RestClient2..ctor (Kusto.Data.KustoConnectionStringBuilder kcsb, System.Boolean canForwardTokenToTarget) [0x0002c] in <e31358719a0646d580915bb27daf320c>:0 
  at Kusto.Data.Net.Client.RestClient2..ctor (Kusto.Data.KustoConnectionStringBuilder kcsb) [0x00000] in <e31358719a0646d580915bb27daf320c>:0 
  at Kusto.Data.Net.Client.KustoClientFactory.CreateCslQueryProvider (Kusto.Data.KustoConnectionStringBuilder builder) [0x0002e] in <e31358719a0646d580915bb27daf320c>:0 
  at Kusto.Data.Net.Client.KustoClientFactory.CreateCslQueryProvider (System.String connectionString) [0x00020] in <e31358719a0646d580915bb27daf320c>:0 

这可能是我一段时间以来看到的最严重的“你已经触及内核基础”错误,所以我想我需要退后一步。 UtilsKeyNotFoundException 给我的印象是这可能是一个配置问题,但是在搜索具有该名称的任何类时我没有得到任何结果。如果您有此问题的经验,我们将不胜感激您的任何见解。

【问题讨论】:

    标签: c# android .net xamarin azure-data-explorer


    【解决方案1】:

    感谢您报告此问题,这是由于 Android 上有限的 .Net 核心支持造成的。我们将努力修复 SDK,以避免在 Android 中使用缺失的 .Net API。

    作为一种解决方法,请尝试 Java SDK。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-05-07
      • 2021-10-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-11
      • 1970-01-01
      相关资源
      最近更新 更多