试图加载格式不正确的程序

试图加载格式不正确的程序

本文介绍了无法加载文件或程序集' System.Data.SQLite'.或其依赖项之一.试图加载格式不正确的程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的 Aspx 项目上使用64位的 Sqlite .运行项目时,出现以下错误:

I am trying to use 64-bit Sqlite on my Aspx project. When I run the project, I got the following error:

我什至将 Enable 32-Bit Aplications 设置为 True 来解决此问题,但问题仍然存在.我正在使用 .Net 4 Framework .我什至下载了 64位SQlite .dll 并将其包含在我的项目中,但仍然无法解决我的问题.我该怎么办才能解决这个问题?

I even set the Enable 32-Bit Aplications to True to fix the problem, but the issue still persists. I am using .Net 4 Framework. I even downloaded 64-bit SQlite .dll and included it in my project and still it didn’t solve my problem. What can I do to resolve this?

由于我无法发布图片.我正在发布错误日志

Since I couldn't post the image. I am posting the error logs

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

推荐答案

如果您不使用NuGet或更喜欢自己引用sqlite程序集,请确保使用正确的平台版本(x64和x86).

If you do not use NuGet or prefer to reference the sqlite assemblies your self, make sure you use the right platform version (x64 vs x86).

要同时支持两个平台,您可以引用System.Data.SQLite.dll,并为每个平台添加2个单独的文件夹来保存SQLite.Interop.dl.

To support both platform, you can reference the System.Data.SQLite.dll, and adds 2 separate folders for each platform to hold the SQLite.Interop.dl.

从sqlite官方下载站点复制:

Copy from official sqlite download site:

  • bin \ System.Data.SQLite.dll(必需的,仅托管核心程序集)
  • bin \ x86 \ SQLite.Interop.dll(必需,x86本机互操作程序集)
  • bin \ x64 \ SQLite.Interop.dll(必需,x64本机互操作程序集)

使用此设置,您的应用程序可以在x64和x86平台上运行.有关更多详细信息,您可以在以下站点上访问sqlite下载站点:http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki"rel =" noreferrer>此处

With this setup, your app can run in both x64 and x86 platform.For more detail info, you can refer to sqlite download site here

这篇关于无法加载文件或程序集' System.Data.SQLite'.或其依赖项之一.试图加载格式不正确的程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 10:07