无法加载文件或程序集“System.Data.SQLite”或它的一个依赖。试图加载程序格式不正确
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了无法加载文件或程序集“System.Data.SQLite”或它的一个依赖。试图加载程序格式不正确相关的知识,希望对你有一定的参考价值。
我试图使用64位Sqlite
我Aspx
项目。当我运行该项目,我得到了以下错误:
无法加载文件或程序集“System.Data.Sqlite”或它的一个依赖。试图加载程序格式不正确。
我甚至设置Enable 32-Bit Aplications
到True
来解决这个问题,但问题仍然存在。我使用.Net 4 Framework
。我甚至下载64-bit SQlite .dll
,在我的项目包括它和它仍然没有解决我的问题。我能做些什么来解决这个问题?
因为我不能发布图片。我张贴的错误日志
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的组件你的自我,一定要使用正确的平台版本(64 VS 86)。
为了支持这两个平台,你可以参考System.Data.SQLite.dll,并增加了2个独立的文件夹,每个平台举行SQLite.Interop.dl。
从官方源码下载网站复制:
- BIN \ System.Data.SQLite.dll(必需的管理只芯组件)
- BIN \ 86 \ SQLite.Interop.dll(需要,X86天然互操作组件)
- BIN \ 64 \ SQLite.Interop.dll(需要,64本地互操作组件)
有了这个设置,您的应用程序可以同时在x64和x86平台上运行。欲了解更多详细信息,您可以参考源码下载网站here
的NuGet是最终的解决方案对我来说,我是使用64位,因为我的Windows 8.1 64位,但是我应该使用的x86。一旦安装System.Data.SQLite
如果您使用Visual Studio试图通过包管理器安装http://www.nuget.org/packages/system.data.sqlite。这可能帮助与依赖关系树的问题。
以上是关于无法加载文件或程序集“System.Data.SQLite”或它的一个依赖。试图加载程序格式不正确的主要内容,如果未能解决你的问题,请参考以下文章
无法加载文件或程序集 'PayPalAdaptivePaymentsSDK,版本 = 2.12.117.0
无法加载文件或程序集。找到的程序集的清单定义与程序集引用不匹配
无法加载文件或程序集'netstandard,版本 = 2.0.0.0