alpine arm64 与 e_sqlite3' or one of its dependencies 异常解决方法


Microsoft 官方的 Docker 镜像不能直接运行 EFCore,会出现异常:

      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()

《alpine arm64 与 e_sqlite3' or one of its dependencies 异常解决方法》

我们在 Linux 中,打开程序目录的 runtimes 中,找到 linux-arm64 目录,执行 ldd 命令,检测 .so 文件的依赖:

        /lib/ (0xffffa9187000) => /lib/ (0xffffa9187000)
Error loading shared library No such file or directory (needed by
Error relocating __memcpy_chk: symbol not found
Error relocating __memset_chk: symbol not found

发现 缺少 libc 库,可执行以下命令安装:

 apk add libc6-compat

《alpine arm64 与 e_sqlite3' or one of its dependencies 异常解决方法》



电子邮件地址不会被公开。 必填项已用*标注