2014-05-15 12 views
7

Tôi đang cố gắng sử dụng 642 bit Sqlite trên dự án Aspx của mình. Khi tôi chạy dự án, tôi nhận được lỗi sau:Không thể tải tệp hoặc lắp ráp 'System.Data.SQLite' hoặc một trong các phụ thuộc của nó. Một nỗ lực đã được thực hiện để tải chương trình với định dạng không chính xác

Could not load file or assembly ‘System.Data.Sqlite’ or one of its dependencies. An attempt was made to load a program with an incorrect format.

Tôi thậm chí thiết lập các Enable 32-Bit Aplications-True để sửa chữa vấn đề, nhưng vấn đề này vẫn còn dai dẳng. Tôi đang sử dụng .Net 4 Framework. Tôi thậm chí đã tải xuống 64-bit SQlite .dll và đưa nó vào dự án của tôi mà vẫn không giải quyết được vấn đề của tôi. Tôi có thể làm gì để giải quyết vấn đề này?

Vì tôi không thể đăng hình ảnh. Tôi đăng các bản ghi lỗi

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.BadImageFormatException: Could not load file or assembly 'System.Data.SQLite' or one of its dependencies. An attempt was made to load a program with an incorrect format. 

=== Pre-bind state information === 
LOG: User = SANZ\Administrator 
LOG: DisplayName = System.Data.SQLite 
(Partial) 
WRN: Partial binding information was supplied for an assembly: 
WRN: Assembly Name: System.Data.SQLite | Domain ID: 36 
WRN: A partial bind occurs when only part of the assembly display name is provided. 
WRN: This might result in the binder loading an incorrect assembly. 
WRN: It is recommended to provide a fully specified textual identity for the assembly, 
WRN: that consists of the simple name, version, culture, and public key token. 
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue. 
LOG: Appbase = file:///C:/Users/Administrator/Documents/Visual Studio 2010/Projects/StoneCarving/StoneCarving/ 
LOG: Initial PrivatePath = C:\Users\Administrator\Documents\Visual Studio 2010\Projects\StoneCarving\StoneCarving\bin 
Calling assembly : (Unknown). 
=== 
LOG: This bind starts in default load context. 
LOG: Using application configuration file: C:\Users\Administrator\Documents\Visual Studio 2010\Projects\StoneCarving\StoneCarving\web.config 
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. 
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind). 
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/c78c2519/83a165be/System.Data.SQLite.DLL. 
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/c78c2519/83a165be/System.Data.SQLite/System.Data.SQLite.DLL. 
LOG: Attempting download of new URL file:///C:/Users/Administrator/Documents/Visual Studio 2010/Projects/StoneCarving/StoneCarving/bin/System.Data.SQLite.DLL. 
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated. 

Stack Trace: 

[BadImageFormatException: Could not load file or assembly 'System.Data.SQLite' or one of its dependencies. An attempt was made to load a program with an incorrect format.] 
    System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0 
    System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +39 
    System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +132 
    System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +144 
    System.Reflection.Assembly.Load(String assemblyString) +28 
    System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +46 

[ConfigurationErrorsException: Could not load file or assembly 'System.Data.SQLite' or one of its dependencies. An attempt was made to load a program with an incorrect format.] 
    System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +618 
    System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +209 
    System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130 
    System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178 
    System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +94 
    System.Web.Compilation.BuildManager.CallPreStartInitMethods() +332 
    System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +591 

[HttpException (0x80004005): Could not load file or assembly 'System.Data.SQLite' or one of its dependencies. An attempt was made to load a program with an incorrect format.] 
    System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +8946484 
    System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97 
    System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +258 
+0

Bạn có biên dịch chương trình của bạn đặc biệt là 64 bit không? Nếu không, bất cứ khi nào bạn chạy nó trong 32 bit bạn sẽ nhận được lỗi này. –

+0

Bạn đang lưu trữ phiên bản IIS nào? –

+0

Dán tiêu đề câu hỏi của bạn vào Google cho thấy điều này: http://stackoverflow.com/questions/1278929/could-not-load-file-or-assembly-system-data-sqlite. Có thể, câu hỏi của bạn trùng lặp với câu hỏi đó. –

Trả lời

6

Nếu bạn không sử dụng NuGet hoặc muốn tham khảo các hội đồng sqlite, hãy đảm bảo bạn sử dụng đúng phiên bản nền tảng (x64 vs x86).

Để hỗ trợ cả hai nền tảng, bạn có thể tham chiếu System.Data.SQLite.dll và thêm 2 thư mục riêng biệt cho mỗi nền tảng để giữ SQLite.Interop.dl.

Copy từ trang web chính thức sqlite tải:

  • bin \ System.Data.SQLite.dll (bắt buộc, quản lý chỉ lắp ráp core)
  • bin \ x86 \ SQLite.Interop.dll (bắt buộc, x86 mẹ đẻ interop assembly)
  • bin \ x64 \ SQLite.Interop.dll (bắt buộc, x64 mẹ đẻ interop assembly)

Với thiết lập này, ứng dụng của bạn có thể chạy trong cả x64 và x86 nền tảng. Để biết thêm thông tin chi tiết, bạn có thể tham khảo trang web tải về sqlite here

6

NuGet là giải pháp cuối cùng đối với tôi, tôi đã sử dụng x64, vì tôi có cửa sổ 8.1 64 bit, Tuy nhiên tôi nên sử dụng x86. sau khi cài đặt System.Data.SQLite enter image description here

+1

Cảm ơn ý tưởng! Nó đã giúp đỡ tôi. –

+1

Vẫn lỗi tương tự – Jamil

Các vấn đề liên quan

 Các vấn đề liên quan