Issue Publishing with SQLite #100

Closed
opened 2026-01-29 16:30:51 +00:00 by claunia · 9 comments
Owner

Originally created by @jfaquinojr on GitHub (Dec 29, 2017).

Originally assigned to: @GregorBiswanger on GitHub.

How can I change this so dotnet electronize start uses win7-x64 instead of win-x64?


How to repro:

setup getting started code:
https://docs.microsoft.com/en-us/ef/core/get-started/netcore/new-db-sqlite

after everything is said done:

dotnet publish -r win-x64 --output ".\published"

cd \published
dotnet run

Error:

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 DLL 'e_sqlite3': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
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)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at Microsoft.Data.Sqlite.Utilities.BundleInitializer.Initialize()
at Microsoft.Data.Sqlite.SqliteConnection..cctor()
--- End of inner exception stack trace ---
at Microsoft.EntityFrameworkCore.Storage.Internal.SqliteRelationalConnection.CreateDbConnection()
at Microsoft.EntityFrameworkCore.Internal.LazyRef1.get_Value() at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open(Boolean errorsExpected) at Microsoft.EntityFrameworkCore.Storage.Internal.SqliteRelationalConnection.Open(Boolean errorsExpected) at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.BeginTransaction(IsolationLevel isolationLevel) at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(Tuple2 parameters)
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(IEnumerable1 commandBatches, IRelationalConnection connection) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(IReadOnlyList1 entriesToSave)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(Boolean acceptAllChangesOnSuccess)
at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess)
at ConsoleApp.SQLite.Program.Main() in C:\Users<username>\Source\Repos\temp\sqlite_test\Program.cs:line 12

Temp Solution:

dotnet publish -r win7-x64 --output ".\published"

How can I change this so dotnet electronize start uses win7-x64 instead of win-x64?

Environment

.NET Command Line Tools (2.1.2)

Product Information:
Version: 2.1.2
Commit SHA-1 hash: 5695315371

Runtime Environment:
OS Name: Windows
OS Version: 6.1.7601
OS Platform: Windows
RID: win7-x64
Base Path: C:\Program Files\dotnet\sdk\2.1.2\

Microsoft .NET Core Shared Framework Host

Version : 2.0.4
Build : 7f262f453d8c8479b9af91d34c013b3aa05bc1ff

Thanks in advance!

Originally created by @jfaquinojr on GitHub (Dec 29, 2017). Originally assigned to: @GregorBiswanger on GitHub. ### How can I change this so `dotnet electronize start` uses win7-x64 instead of win-x64? -------- ### How to repro: setup getting started code: https://docs.microsoft.com/en-us/ef/core/get-started/netcore/new-db-sqlite after everything is said done: ``` dotnet publish -r win-x64 --output ".\published" cd \published dotnet run ``` ### Error: > 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 DLL 'e_sqlite3': The specified module could not be found. (Exception from HRESULT: 0x8007007E) > 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) > --- End of inner exception stack trace --- > at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) > at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) > at Microsoft.Data.Sqlite.Utilities.BundleInitializer.Initialize() > at Microsoft.Data.Sqlite.SqliteConnection..cctor() > --- End of inner exception stack trace --- > at Microsoft.EntityFrameworkCore.Storage.Internal.SqliteRelationalConnection.CreateDbConnection() > at Microsoft.EntityFrameworkCore.Internal.LazyRef`1.get_Value() > at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open(Boolean errorsExpected) > at Microsoft.EntityFrameworkCore.Storage.Internal.SqliteRelationalConnection.Open(Boolean errorsExpected) > at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.BeginTransaction(IsolationLevel isolationLevel) > at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(Tuple`2 parameters) > at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(IEnumerable`1 commandBatches, IRelationalConnection connection) > at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(IReadOnlyList`1 entriesToSave) > at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(Boolean acceptAllChangesOnSuccess) > at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess) > at ConsoleApp.SQLite.Program.Main() in C:\Users\<username>\Source\Repos\temp\sqlite_test\Program.cs:line 12 ## Temp Solution: `dotnet publish -r win7-x64 --output ".\published"` How can I change this so `dotnet electronize start` uses win7-x64 instead of win-x64? ### Environment .NET Command Line Tools (2.1.2) Product Information: Version: 2.1.2 Commit SHA-1 hash: 5695315371 Runtime Environment: OS Name: Windows OS Version: 6.1.7601 OS Platform: Windows RID: win7-x64 Base Path: C:\Program Files\dotnet\sdk\2.1.2\ Microsoft .NET Core Shared Framework Host Version : 2.0.4 Build : 7f262f453d8c8479b9af91d34c013b3aa05bc1ff Thanks in advance!
Author
Owner

@robertmuehsig commented on GitHub (Jan 18, 2018):

Interesting - I'm not sure why it needs to be win7-x64. We started with the "win10" rid and later @Petermarcu send us a PR to use the more general rid.

@Petermarcu : Any idea why it is sometimes needed to be more "specific"?

@robertmuehsig commented on GitHub (Jan 18, 2018): Interesting - I'm not sure why it needs to be win7-x64. We started with the "win10" rid and later @Petermarcu send us a PR to use the more general rid. @Petermarcu : Any idea why it is sometimes needed to be more "specific"?
Author
Owner

@robertmuehsig commented on GitHub (Jan 18, 2018):

I try to add some options for the build and start command - maybe we need the ability to overwrite the default values.

@robertmuehsig commented on GitHub (Jan 18, 2018): I try to add some options for the build and start command - maybe we need the ability to overwrite the default values.
Author
Owner

@Petermarcu commented on GitHub (Jan 19, 2018):

It's likely because Sqlite has a native asset and isn't providing a win-x64. I'd have to take a closer look to be sure.

@Petermarcu commented on GitHub (Jan 19, 2018): It's likely because Sqlite has a native asset and isn't providing a win-x64. I'd have to take a closer look to be sure.
Author
Owner

@Petermarcu commented on GitHub (Jan 19, 2018):

I was able to repro this. Note that you can't dotnet run from the publish folder from the repro steps but I'm guessing that you just ran the app.

It is as I suspected. Sqlite should be providing a win-x64 asset as a default asset to use if nothing more specific is specified. You can see the win7 that I pulled from the .deps.json file of my repro project.

"SQLitePCLRaw.lib.e_sqlite3.v110_xp/1.1.7": {
        "native": {
          "runtimes/win7-x64/native/e_sqlite3.dll": {}
        }
      },

I'm looking to see where we can open an issue and finding exactly the right package that needs to be updated.

@Petermarcu commented on GitHub (Jan 19, 2018): I was able to repro this. Note that you can't `dotnet run` from the publish folder from the repro steps but I'm guessing that you just ran the app. It is as I suspected. Sqlite should be providing a win-x64 asset as a default asset to use if nothing more specific is specified. You can see the win7 that I pulled from the .deps.json file of my repro project. ``` "SQLitePCLRaw.lib.e_sqlite3.v110_xp/1.1.7": { "native": { "runtimes/win7-x64/native/e_sqlite3.dll": {} } }, ``` I'm looking to see where we can open an issue and finding exactly the right package that needs to be updated.
Author
Owner

@Petermarcu commented on GitHub (Jan 19, 2018):

Ok, its this package. https://www.nuget.org/packages/SQLitePCLRaw.lib.e_sqlite3.v110_xp/

@Petermarcu commented on GitHub (Jan 19, 2018): Ok, its this package. https://www.nuget.org/packages/SQLitePCLRaw.lib.e_sqlite3.v110_xp/
Author
Owner

@Petermarcu commented on GitHub (Jan 19, 2018):

I've been trying to find a workaround. I was trying to find a way to hack the NuGet cache to fix the package in place but that was causing other side effects. I was able to get it to work by copying the file from here: C:\Program Files\dotnet\sdk\NuGetFallbackFolder\sqlitepclraw.lib.e_sqlite3.v110_xp\1.1.7\runtimes\win7-x64\native into the published output folder manually.

@Petermarcu commented on GitHub (Jan 19, 2018): I've been trying to find a workaround. I was trying to find a way to hack the NuGet cache to fix the package in place but that was causing other side effects. I was able to get it to work by copying the file from here: `C:\Program Files\dotnet\sdk\NuGetFallbackFolder\sqlitepclraw.lib.e_sqlite3.v110_xp\1.1.7\runtimes\win7-x64\native` into the published output folder manually.
Author
Owner

@robertmuehsig commented on GitHub (Jan 19, 2018):

Wow - thanks a lot! Until the package is "fixed": My plan is to add some options to our "build"/"start" command to overwrite some of our arguments (e.g. release/debug or which arch).

@robertmuehsig commented on GitHub (Jan 19, 2018): Wow - thanks a lot! Until the package is "fixed": My plan is to add some options to our "build"/"start" command to overwrite some of our arguments (e.g. release/debug or which arch).
Author
Owner

@Petermarcu commented on GitHub (Jan 19, 2018):

Sounds good :) I made a PR that I think fixes the package: https://github.com/ericsink/SQLitePCL.raw/pull/195 not sure if/when it will be merged.

@Petermarcu commented on GitHub (Jan 19, 2018): Sounds good :) I made a PR that I think fixes the package: https://github.com/ericsink/SQLitePCL.raw/pull/195 not sure if/when it will be merged.
Author
Owner

@robertmuehsig commented on GitHub (Feb 19, 2018):

We released a new version and now support addional params for the build command like this:

dotnet electronize build /target custom win7-x86;win32 /electron-arch ia32

The "custom" target can be used to specify the desired .NET Core platform and the desired electron packager platform. Be aware that the electron packager itself has an addional parameter called arch, which specifies x86/x64 etc.

For the SQLLite issue you may want to use "/target custom win7-x64;win32".

You should now be able to mix everything that you want :)

Just update the CLI to version 0.0.9

@robertmuehsig commented on GitHub (Feb 19, 2018): We released a new version and now support addional params for the build command like this: dotnet electronize build /target custom win7-x86;win32 /electron-arch ia32 The "custom" target can be used to specify the desired .NET Core platform and the desired electron packager platform. Be aware that the electron packager itself has an addional parameter called arch, which specifies x86/x64 etc. For the SQLLite issue you may want to use "/target custom win7-x64;win32". You should now be able to mix everything that you want :) Just update the CLI to version 0.0.9
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#100