Исключения при вызове Kusto API в среде Android

#c# #android #.net #xamarin #azure-data-explorer

#c# #Android #.net #xamarin #azure-data-explorer

Вопрос:

Я работаю над мобильным приложением Xamarin, которое запрашивает некоторые данные, находящиеся в кластере ADX. Я настроил проект с использованием Kusto SDK и тестирую с помощью обучающего кода здесь:

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

 

Я тестирую Android-эмулятор Visual Studio (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 
 

Документация, похоже, показывает, что этот код участвует в трассировке на стороне клиента, поэтому я решил отключить его с помощью кода, который он предоставляет:

 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.Stringamp; 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 создает у меня впечатление, что это может быть проблемой конфигурации, но я не получаю результатов при поиске любого класса с таким именем. Если у вас есть опыт работы с этой проблемой, мы будем очень признательны за любую имеющуюся у вас информацию.

Ответ №1:

Спасибо, что сообщили об этом, это результат ограниченного .Поддержка Net core на Android. Мы будем работать над исправлением SDK, чтобы избежать использования отсутствующих .Net API в Android.

В качестве обходного пути, пожалуйста, попробуйте Java SDK.