Closed zmj closed 1 year ago
On Windows:
Error Message:
System.TypeInitializationException : The type initializer for 'Sqlite.Fast.Connection' threw an exception.
---- System.Exception : Library e_sqlite3 not found
plat: win
suffix: DLL
possibilities (2):
1) C:\Users\zmj\AppData\Local\Temp\d5e5718b-ca74-4b1d-8c7d-e3b7f63a95fa\d5e5718b-ca74-4b1d-8c7d-e3b7f63a95fa\assembly\dl3\bbda9fce\004c6898_94cbd801\runtimes\win-x86\native\e_sqlite3.dll
2) C:\Users\zmj\AppData\Local\Temp\d5e5718b-ca74-4b1d-8c7d-e3b7f63a95fa\d5e5718b-ca74-4b1d-8c7d-e3b7f63a95fa\assembly\dl3\bbda9fce\004c6898_94cbd801\e_sqlite3.dll
win TryLoad: C:\Users\zmj\AppData\Local\Temp\d5e5718b-ca74-4b1d-8c7d-e3b7f63a95fa\d5e5718b-ca74-4b1d-8c7d-e3b7f63a95fa\assembly\dl3\bbda9fce\004c6898_94cbd801\runtimes\win-x86\native\e_sqlite3.dll
thrown: System.ComponentModel.Win32Exception (0x80004005): The specified module could not be found
at SQLitePCL.NativeLibrary.TryLoad(String name, Loader plat, Action`1 log, IntPtr& h)
win TryLoad: C:\Users\zmj\AppData\Local\Temp\d5e5718b-ca74-4b1d-8c7d-e3b7f63a95fa\d5e5718b-ca74-4b1d-8c7d-e3b7f63a95fa\assembly\dl3\bbda9fce\004c6898_94cbd801\e_sqlite3.dll
thrown: System.ComponentModel.Win32Exception (0x80004005): The specified module could not be found
at SQLitePCL.NativeLibrary.TryLoad(String name, Loader plat, Action`1 log, IntPtr& h)
NOT FOUND
Stack Trace:
at Sqlite.Fast.Connection..ctor()
at Sqlite.Fast.Tests.TestTable..ctor(String createTableSql) in D:\sqlite-fast\Sqlite.Fast.Tests\TestTable.cs:line 13
at Sqlite.Fast.Tests.ConverterTests.Custom_ToBlob() in D:\sqlite-fast\Sqlite.Fast.Tests\ConverterTests.cs:line 226
----- Inner Stack Trace -----
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()
at Sqlite.Fast.Connection..cctor() in D:\sqlite-fast\Sqlite.Fast\Connection.cs:line 15
I cloned your repo and reproduced the problem.
Then I added a file called xunit.runner.json
into Sqlite.Fast.Tests
, containing:
{
"shadowCopy": false
}
Then I added this snippet to Sqlite.Fast.Tests.csproj
:
<ItemGroup>
<None Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
After that dotnet test
works.
This is a common problem when using xunit with .NET Framework.
Thank you! That fixed things.
I'm trying to add a .NET Framework target to the tests for an existing project. The test project references a .NET Standard wrapper library that PackageReferences a SQLitePCL.raw bundle:
Library csproj: https://github.com/zmj/sqlite-fast/blob/master/Sqlite.Fast/Sqlite.Fast.csproj Test csproj: https://github.com/zmj/sqlite-fast/blob/master/Sqlite.Fast.Tests/Sqlite.Fast.Tests.csproj Batteries.Init call: https://github.com/zmj/sqlite-fast/blob/master/Sqlite.Fast/Connection.cs#L15
On Mono / M1 Mac, the tests fail on the Batteries.Init call. They also fail on Windows 11 x64 with a similar error. I'll add that output in a comment.
dotnet test output:
Looking at the existing open issues, I see some workarounds supplying explicit RuntimeIdentifiers. Is that something I should be doing?
Template info:
2.1.2. Also tried 2.0.7, same error.
Tried green and e_sqlite3.
OSX Ventura, M1 Pro. WIndows 11 x64.
net462. Also tried net48, same error.
Framework.
Command line. On Windows, the error message is the same in Visual Studio 2022.
No. I'm trying to add a net framework target to tests that were previously netcore only.
See above.
PackageReference
N/A
Minimal. See csproj links above.
Clone the repository (links above) and run the tests.