2011-01-13 23 views
1

私はclr.AddReferenceを使用して、単純なIronPythonプログラムにsqlite3機能を追加しようとしています。しかし、毎回私はこのエラーを取得するSystem.Data.SQLiteを参照しよう:IronPythonでSystem.Data.SQLite参照を追加する

Traceback (most recent call last): File "", line 1, in IOError: System.IO.IOException: Could not add reference to assembly System.Data.SQLite
at Microsoft.Scripting.Actions.Calls.MethodCandidate.Caller.Call(Object[] args, Boolean&shouldOptimize)
at IronPython.Runtime.Types.BuiltinFunction.BuiltinFunctionCaller 2.Call1(CallSite site, CodeContext context, TFuncType func, T0 arg0)
at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)
at CallSite.Target(Closure , CallSite , CodeContext , Object , Object)
at IronPython.Compiler.Ast.CallExpression.Invoke1Instruction.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
at IronPython.Runtime.FunctionCode.Call(CodeContext context)
at IronPython.Runtime.Operations.PythonOps.QualifiedExec(CodeContext context, Object code, PythonDictionary globals, Object locals)
at Microsoft.Scripting.Interpreter.ActionCallInstruction
4.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)

私は主に通訳での輸入や参照をテストしてきた、そしてこれらは私がテストラインです:

import sys
import clr
sys.path.append("C:/Program Files (x86)/SQLite.NET/bin")
clr.AddReference("System.Data.SQLite")

エラーは、clr.AddReference行が入力された後に発生します。どのように私はSystem.Data.SQLiteを正しく追加しますか?

+0

私はSQLite.NETをダウンロードし、サンプルコードは完全に私のために動作します。 SQLiteへのパスをダブルチェックしてください。 – Cameron

答えて

1

まず、x86(32ビット)System.Data.SQLite.dllをx64(64ビット)プロセスに読み込もうとしているか、その逆です。 System.Data.SQLite.dllには、x86またはx64用にコンパイルする必要があるネイティブsqlite3ライブラリが含まれているため、各CPU用のSystem.Data.SQLite.dllが存在します。

コンソールを使用している場合、ipy.exeは、常に32ビット(64ビットプラットフォームでも)ipy64.exeがAnyCPUであるため、現在のプラットフォームと一致します。 IronPythonをホストしていて、ホストアプリケーションがAnyCPUの場合は、実行しているマシンのSystem.Data.SQLite.dllの正しいコピーをロードする必要があります(またはホストアプリケーションx86のみを強制する)。

関連する問題