Answer the question
In order to leave comments, you need to log in
How to make an application using SQLite WinForms.Net work on both 32 and 64 bit systems?
As far as I understand, the System.Data.SQLite libraries require undmanaged SQLite libraries for their work, which are available for 64 and 32-bit versions of Windows. How to make such an application that will connect the appropriate version depending on which machine it is running on?
Answer the question
In order to leave comments, you need to log in
I did it in 2 ways, I can’t describe one now, it’s too cumbersome (and it doesn’t allow you to change it in runtime, you still have to build 2 versions of the application).
Here is a simpler option stackoverflow.com/questions/11934570/change-c-shar... You
need to put the x86 and x64 libraries in the appropriate folders, and put the code in the Main method as indicated there.
Although in principle you can try using MEF here, you will need .NET 4.5 at least here.
This can be done using the built-in feature of System.Data.SQLite, which looks for the version of SQLite.Interop.dll, not only next to itself, but also in the directory, resp. architecture, i.e. x86 or x64 respectively.
See Using Native Library Pre-Loading on their wiki .
Did it like this:
<Content Include="..\..\..\cs\Common\SQLite\x86\SQLite.Interop.dll">
<Link>x86\SQLite.Interop.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\..\..\cs\Common\SQLite\x86\SQLite.Interop.pdb">
<Link>x86\SQLite.Interop.pdb</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\..\..\cs\Common\SQLite\x64\SQLite.Interop.dll">
<Link>x64\SQLite.Interop.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\..\..\cs\Common\SQLite\x64\SQLite.Interop.pdb">
<Link>x64\SQLite.Interop.pdb</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question