Closed anandnandagiri closed 1 year ago
Which SQLitePCLRaw package and what version are you using?
It would be helpful if you can post a minimal repro project.
here is a minimal repo that I have uploaded. https://github.com/anandnandagiri/MyPOC/tree/master/.NET%20Core/.NET%206/SQLite
Also provided readmefile with steps since I am using docker in Raspberry PI
Your repro sample isn't terribly "minimal". It's hard to figure out what might be going wrong when there are extra pieces in play.
I just tried this:
mkdir issue491
cd issue491
dotnet new console
dotnet add package sqlitepclraw.bundle_e_sqlite3
dotnet publish -c Release -r linux-arm64 --self-contained=false
The proper native file (libe_sqlite3.so
) is present in the publish output directory where it should be.
I see native file (libe_sqlite3.so) is been in publish folder
As suggest place simple project https://github.com/anandnandagiri/MyPOC/tree/master/.NET%20Core/.NET%206/issue491. But still I am seeing the issue on pi4.
Hmmm. So maybe there's something wrong with that libe_sqlite3.so
file. Although, I tend to think that if the Linux/Arm64 build was fundamentally broken I would be hearing about it from other people.
Anyway, if the file is in the right place, we need to know WHY it isn't loading. The best guess is that it needs a library that is not present on the system.
I don't have a Pi4 to use for testing. Can you try running the executable with LD_DEBUG set as mentioned in the error message?
What OS is running on the Pi?
PI OS Details
I tried following way to enable LD_DEBUG but on console it is not displaying nothing...
Not sure if you saw this mention on the "other issue", but I'm curious if the problem might be mixing Alpine and regular Linux. The dotnet publish
command is using a RID of linux-arm64
, which, if I understand correctly, is the wrong RID for Alpine.
With above RID linux-arm64 I used below Dockerfile FROM mcr.microsoft.com/dotnet/aspnet:latest AS runtime WORKDIR /app COPY . . ENTRYPOINT ["dotnet", "issue491.dll"]
It worked perfectly on PI
But as per documentation https://docs.microsoft.com/en-us/dotnet/core/rid-catalog I used RID linux-musl-x64 FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine3.14 AS runtime WORKDIR /app COPY . . EXPOSE 8080 ENTRYPOINT ["dotnet", "issue491.dll","--environment=PI"]
This is causing issues
But linux-musl-x64 is Intel and the Pi is ARM, right?
for sure PI is ARM. not sure in the case of RID linux-musl-x64 is Intel since in the documentation it mentioned it supports Alpine I used it but when I run with docker it is failing (I am using alpine since the docker image is less than other Linux images)
in another way, it shows it works on Raspberry PI if we take any image other than Alpine.
linux-musl-x64 is Intel
For a PI, you would need an arm64 version of Alpine, and the corresponding RID, which I believe is linux-musl-arm64.
I tired RID linux-musl-arm64 which is not there in the documentation.. this is also falling with the same issue
Unhandled 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: libe_sqlite3: cannot open shared object file: No such file or directory
But when you try using linux-musl-arm64, are you using an arm64 version of Alpine?
My bad I used the other image. Now I corrected it to work perfectly. Thank You So much for the quick responses.
I am using .NET 6 it working fine when i run on window machine but when i deploy to Raspberry PI ARM64 it is causing issue.
dotnet publish -c Release -r linux-arm64 --self-contained=false
Below is the log
{"EventId":10000,"LogLevel":"Error","Category":"Microsoft.EntityFrameworkCore.Update","Message":"An exception occurred in the database while saving changes for context type \u0027Praveshanam.Models.praveshanamContext\u0027.\nSystem.TypeInitializationException: The type initializer for \u0027Microsoft.Data.Sqlite.SqliteConnection\u0027 threw an exception.\n ---\u003E System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.\n ---\u003E System.DllNotFoundException: Unable to load shared library \u0027e_sqlite3\u0027 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\n at SQLitePCL.SQLite3Provider_e_sqlite3.NativeMethods.sqlite3_libversion_number()\n at SQLitePCL.SQLite3Provider_e_sqlite3.SQLitePCL.ISQLite3Provider.sqlite3_libversion_number()\n at SQLitePCL.raw.SetProvider(ISQLite3Provider imp)\n at SQLitePCL.Batteries_V2.Init()\n --- End of inner exception stack trace ---\n at System.RuntimeMethodHandle.InvokeMethod(Object target, Span\u00601\u0026 arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)\n at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)\n at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)\n at Microsoft.Data.Sqlite.Utilities.BundleInitializer.Initialize()\n at Microsoft.Data.Sqlite.SqliteConnection..cctor()\n --- End of inner exception stack trace ---\n at Microsoft.Data.Sqlite.SqliteConnection..ctor(String connectionString)\n at Microsoft.EntityFrameworkCore.Sqlite.Storage.Internal.SqliteRelationalConnection.CreateDbConnection()\n at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.get_DbConnection()\n at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open(Boolean errorsExpected)\n at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.BeginTransaction(IsolationLevel isolationLevel)\n at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.BeginTransaction()\n at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(IEnumerable\u00601 commandBatches, IRelationalConnection connection)\n at Microsoft.EntityFrameworkCore.Storage.RelationalDatabase.SaveChanges(IList\u00601 entries)\n at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(IList\u00601 entriesToSave)\n at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(StateManager stateManager, Boolean acceptAllChangesOnSuccess)\n at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.\u003C\u003Ec.\u003CSaveChanges\u003Eb1040(DbContext , ValueTuple\u00602 t)\n at Microsoft.EntityFrameworkCore.Storage.NonRetryingExecutionStrategy.Execute[TState,TResult](TState state, Func\u00603 operation, Func\u00603 verifySucceeded)\n at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(Boolean acceptAllChangesOnSuccess)\n at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess)","Exception":"System.TypeInitializationException: The type initializer for \u0027Microsoft.Data.Sqlite.SqliteConnection\u0027 threw an exception. ---\u003E System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---\u003E System.DllNotFoundException: Unable to load shared library \u0027e_sqlite3\u0027 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 SQLitePCL.SQLite3Provider_e_sqlite3.NativeMethods.sqlite3_libversion_number() at SQLitePCL.SQLite3Provider_e_sqlite3.SQLitePCL.ISQLite3Provider.sqlite3_libversion_number() at SQLitePCL.raw.SetProvider(ISQLite3Provider imp) at SQLitePCL.Batteries_V2.Init() --- End of inner exception stack trace --- at System.RuntimeMethodHandle.InvokeMethod(Object target, Span\u00601\u0026 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() --- End of inner exception stack trace --- at Microsoft.Data.Sqlite.SqliteConnection..ctor(String connectionString) at Microsoft.EntityFrameworkCore.Sqlite.Storage.Internal.SqliteRelationalConnection.CreateDbConnection() at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.get_DbConnection() at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open(Boolean errorsExpected) at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.BeginTransaction(IsolationLevel isolationLevel) at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.BeginTransaction() at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(IEnumerable\u00601 commandBatches, IRelationalConnection connection) at Microsoft.EntityFrameworkCore.Storage.RelationalDatabase.SaveChanges(IList\u00601 entries) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(IList\u00601 entriesToSave) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(StateManager stateManager, Boolean acceptAllChangesOnSuccess) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.\u003C\u003Ec.\u003CSaveChanges\u003Eb__1040(DbContext , ValueTuple\u00602 t) at Microsoft.EntityFrameworkCore.Storage.NonRetryingExecutionStrategy.Execute[TState,TResult](TState state, Func\u00603 operation, Func\u00603 verifySucceeded) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(Boolean acceptAllChangesOnSuccess) at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess)","State":{"Message":"An exception occurred in the database while saving changes for context type \u0027Praveshanam.Models.praveshanamContext\u0027.\nSystem.TypeInitializationException: The type initializer for \u0027Microsoft.Data.Sqlite.SqliteConnection\u0027 threw an exception.\n ---\u003E System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.\n ---\u003E System.DllNotFoundException: Unable to load shared library \u0027e_sqlite3\u0027 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\n at SQLitePCL.SQLite3Provider_e_sqlite3.NativeMethods.sqlite3_libversion_number()\n at SQLitePCL.SQLite3Provider_e_sqlite3.SQLitePCL.ISQLite3Provider.sqlite3_libversion_number()\n at SQLitePCL.raw.SetProvider(ISQLite3Provider imp)\n at SQLitePCL.Batteries_V2.Init()\n --- End of inner exception stack trace ---\n at System.RuntimeMethodHandle.InvokeMethod(Object target, Span\u00601\u0026 arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)\n at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)\n at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)\n at Microsoft.Data.Sqlite.Utilities.BundleInitializer.Initialize()\n at Microsoft.Data.Sqlite.SqliteConnection..cctor()\n --- End of inner exception stack trace ---\n at Microsoft.Data.Sqlite.SqliteConnection..ctor(String connectionString)\n at Microsoft.EntityFrameworkCore.Sqlite.Storage.Internal.SqliteRelationalConnection.CreateDbConnection()\n at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.get_DbConnection()\n at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open(Boolean errorsExpected)\n at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.BeginTransaction(IsolationLevel isolationLevel)\n at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.BeginTransaction()\n at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(IEnumerable\u00601 commandBatches, IRelationalConnection connection)\n at Microsoft.EntityFrameworkCore.Storage.RelationalDatabase.SaveChanges(IList\u00601 entries)\n at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(IList\u00601 entriesToSave)\n at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(StateManager stateManager, Boolean acceptAllChangesOnSuccess)\n at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.\u003C\u003Ec.\u003CSaveChanges\u003Eb1040(DbContext , ValueTuple\u00602 t)\n at Microsoft.EntityFrameworkCore.Storage.NonRetryingExecutionStrategy.Execute[TState,TResult](TState state, Func\u00603 operation, Func\u00603 verifySucceeded)\n at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(Boolean acceptAllChangesOnSuccess)\n at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess)","contextType":"Praveshanam.Models.praveshanamContext","newline":"\n","error":"System.TypeInitializationException: The type initializer for \u0027Microsoft.Data.Sqlite.SqliteConnection\u0027 threw an exception.\n ---\u003E System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.\n ---\u003E System.DllNotFoundException: Unable to load shared library \u0027e_sqlite3\u0027 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\n at SQLitePCL.SQLite3Provider_e_sqlite3.NativeMethods.sqlite3_libversion_number()\n at SQLitePCL.SQLite3Provider_e_sqlite3.SQLitePCL.ISQLite3Provider.sqlite3_libversion_number()\n at SQLitePCL.raw.SetProvider(ISQLite3Provider imp)\n at SQLitePCL.Batteries_V2.Init()\n --- End of inner exception stack trace ---\n at System.RuntimeMethodHandle.InvokeMethod(Object target, Span\u00601\u0026 arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)\n at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)\n at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)\n at Microsoft.Data.Sqlite.Utilities.BundleInitializer.Initialize()\n at Microsoft.Data.Sqlite.SqliteConnection..cctor()\n --- End of inner exception stack trace ---\n at Microsoft.Data.Sqlite.SqliteConnection..ctor(String connectionString)\n at Microsoft.EntityFrameworkCore.Sqlite.Storage.Internal.SqliteRelationalConnection.CreateDbConnection()\n at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.get_DbConnection()\n at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open(Boolean errorsExpected)\n at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.BeginTransaction(IsolationLevel isolationLevel)\n at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.BeginTransaction()\n at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(IEnumerable\u00601 commandBatches, IRelationalConnection connection)\n at Microsoft.EntityFrameworkCore.Storage.RelationalDatabase.SaveChanges(IList\u00601 entries)\n at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(IList\u00601 entriesToSave)\n at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(StateManager stateManager, Boolean acceptAllChangesOnSuccess)\n at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.\u003C\u003Ec.\u003CSaveChanges\u003Eb__1040(DbContext , ValueTuple\u00602 t)\n at Microsoft.EntityFrameworkCore.Storage.NonRetryingExecutionStrategy.Execute[TState,TResult](TState state, Func\u00603 operation, Func\u00603 verifySucceeded)\n at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(Boolean acceptAllChangesOnSuccess)\n at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess)","{OriginalFormat}":"An exception occurred in the database while saving changes for context type \u0027{contextType}\u0027.{newline}{error}"}}