2011-01-13 2 views
1

나는 clr.AddReference를 사용하여 간단한 IronPython 프로그램에 sqlite3 기능을 추가하려고합니다. 내가 주로 통역의 수입과 참고 문헌을 테스트 있었고, 이러한 선이다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)

I 테스트 :하지만 매번 나는이 오류가 System.Data.SQLite를 참조하려고

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

내 생각 엔 x64 (64 비트) 프로세스에서 x86 (32 비트) System.Data.SQLite.dll을로드하려고하거나 그 반대의 경우입니다. System.Data.SQLite.dll에는 x86 또는 x64 용으로 컴파일해야하는 네이티브 sqlite3 라이브러리가 포함되어 있으므로 각 CPU에 대해 System.Data.SQLite.dll 버전이 있습니다.

콘솔을 사용 중이라면 ipy.exe는 ipy64.exe가 AnyCPU 인 동안 항상 32 비트 (64 비트 플랫폼에서도)이므로 현재 플랫폼과 일치합니다. IronPython을 호스팅하고 있고 호스트 응용 프로그램이 AnyCPU 인 경우 실행중인 시스템에 대해 System.Data.SQLite.dll의 올바른 복사본을로드해야합니다 (또는 호스트 응용 프로그램 x86 만 강제 실행).