Azure / azure-kusto-dotnet

Azure Data Explorer (Kusto) SDK for .NET
MIT License
6 stars 3 forks source link

Unhandled exception. System.TypeInitializationException: The type initializer for 'Kusto.Cloud.Platform.Utils.NativeThread' threw an exception. #26

Closed Nishanth32 closed 6 months ago

Nishanth32 commented 6 months ago

My Aspnet core web app uses "Microsoft.Azure.Kusto.Ingest" NuGet package for routine ADX data ingestion. As part of our dotnet 8 migration, I recently upgraded the NuGet package from version "11.2.2" to "12.0.0". While the updated NuGet version functions smoothly on the local windows environment, deployment to Azure ACA containers (docker image targets a Linux OS) results in failure. The exception seems to originate from the Kusto.Cloud.Platform.Utils.NativeThread class.

Unhandled exception. System.TypeInitializationException: The type initializer for 'Kusto.Cloud.Platform.Utils.NativeThread' threw an exception.
---> System.DllNotFoundException: Unable to load shared library 'kernel32.dll' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable:
/usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.0/kernel32.dll.so: cannot open shared object file: No such file or directory
/app/kernel32.dll.so: cannot open shared object file: No such file or directory
/usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.0/libkernel32.dll.so: cannot open shared object file: No such file or directory
/app/libkernel32.dll.so: cannot open shared object file: No such file or directory
/usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.0/kernel32.dll: cannot open shared object file: No such file or directory
/app/kernel32.dll: cannot open shared object file: No such file or directory
/usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.0/libkernel32.dll: cannot open shared object file: No such file or directory
/app/libkernel32.dll: cannot open shared object file: No such file or directory
...
at Kusto.Cloud.Platform.Utils.NativeThread.GetCurrentThread()
at Kusto.Cloud.Platform.Utils.NativeThread..ctor()
--- End of inner exception stack trace ---
at Kusto.Cloud.Platform.Utils.NativeThread.GetThreadDescription()
at Kusto.Cloud.Platform.Utils.PeriodicNonoverlappingTimer.OnTimerCallback(Object context)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)

Upon investigation, it appears that the "12.0.0" version introduced the Kusto.Cloud.Platform.Utils.NativeThread class, which engages in unmanaged operations with a dependency to load window specific "kernel32.dll" library. Any guidance on resolving this issue would be greatly appreciated. image

barnstee commented 6 months ago

The new NuGet 12.0.1 fixes this for me.

yogilad commented 6 months ago

This issue was fixed in 12.0.1