Solution to the Exception "alpine arm64 and e_sqlite3' or one of its dependencies"

2020年12月10日 72点热度 3人点赞 0条评论
内容目录

Microsoft's official Docker images cannot run EFCore directly, resulting in the following exception:

      System.TypeInitializationException: The type initializer for 'Microsoft.Data.Sqlite.SqliteConnection' threw an exception.
       ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
       ---> System.DllNotFoundException: Unable to load shared library 'e_sqlite3' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: Error loading shared library libe_sqlite3: No such file or directory
         at System.Runtime.InteropServices.NativeLibrary.LoadByName(String libraryName, QCallAssembly callingAssembly, Boolean hasDllImportSearchPathFlag, UInt32 dllImportSearchPathFlag, Boolean throwOnError)
         at System.Runtime.InteropServices.NativeLibrary.LoadLibraryByName(String libraryName, Assembly assembly, Nullable`1 searchPath, Boolean throwOnError)
         at System.Runtime.InteropServices.NativeLibrary.Load(String libraryName, Assembly assembly, Nullable`1 searchPath)
         at SQLitePCL.NativeLibrary.Load(String libraryName, Assembly assy, Int32 flags)
         at SQLitePCL.Batteries_V2.MakeDynamic(String name, Int32 flags)
         at SQLitePCL.Batteries_V2.DoDynamic_cdecl(String name, Int32 flags)
         at SQLitePCL.Batteries_V2.Init()
         --- End of inner exception stack trace ---
         at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
         at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
         at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
         at Microsoft.Data.Sqlite.Utilities.BundleInitializer.Initialize()
         at Microsoft.Data.Sqlite.SqliteConnection..cctor()

file

In Linux, we can open the program directory's runtimes, locate the linux-arm64 directory, and execute the ldd command to check the dependencies of the .so file:

 ldd libe_sqlite3.so
        /lib/ld-musl-aarch64.so.1 (0xffffa9187000)
        libc.so.6 => /lib/ld-musl-aarch64.so.1 (0xffffa9187000)
Error loading shared library ld-linux-aarch64.so.1: No such file or directory (needed by libe_sqlite3.so)
Error relocating libe_sqlite3.so: __memcpy_chk: symbol not found
Error relocating libe_sqlite3.so: __memset_chk: symbol not found

We find that the libc library is missing; you can install it with the following command:

 apk add libc6-compat

Restart the program or container, and it should work normally.

file

痴者工良

高级程序员劝退师

文章评论