Using SQLite from PowerShell on Windows 7x64?
Posted
by
jas
on Stack Overflow
See other posts from Stack Overflow
or by jas
Published on 2010-12-29T08:32:25Z
Indexed on
2010/12/30
3:54 UTC
Read the original article
Hit count: 267
I'm having a difficult time trying to load System.Data.SQLite.dll from PowerShell in Windows 7 x64.
# x64
[void][System.Reflection.Assembly]::LoadFrom("C:\projects\PSScripts\lib\System.Data.SQLite.x64.DLL")
# x86
#[void][System.Reflection.Assembly]::LoadFrom("C:\projects\PSScripts\lib\System.Data.SQLite.DLL")
$conn = New-Object -TypeName System.Data.SQLite.SQLiteConnection
$conn.ConnectionString = "Data Source=C:\temp\PSData.db"
$conn.Open()
$command = $conn.CreateCommand()
$command.CommandText = "select DATETIME('NOW') as now, 'Bar' as Foo"
$adapter = New-Object -TypeName System.Data.SQLite.SQLiteDataAdapter $command
$dataset = New-Object System.Data.DataSet
[void]$adapter.Fill($dataset)
Trying to open the connection with the x64 assembly results in:
Exception calling "Open" with "0" argument(s): "An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)"
Trying to load the x86 assembly results in:
Exception calling "LoadFrom" with "1" argument(s): "Could not load file or assembly 'file:///C:\projects\PSScripts\lib\System.Data.SQLite.DLL' or one of its dependencies. An attempt was made to load a program with an incorrect format."
Any thoughts or ideas?
© Stack Overflow or respective owner