Rootop 服务器运维与web架构

Could not load file or assembly ‘System.Data.SQLite’ or one of its dependencies. 试图加载格式不正确的程序。

| 暂无评论

 

Server Error in ‘/’ Application.


Could not load file or assembly ‘System.Data.SQLite’ or one of its dependencies. 试图加载格式不正确的程序。

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. 试图加载格式不正确的程序。

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Assembly Load Trace: The following information can be helpful to determine why the assembly ‘System.Data.SQLite’ could not be loaded.

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

 

Stack Trace:

[BadImageFormatException: Could not load file or assembly 'System.Data.SQLite' or one of its dependencies. 试图加载格式不正确的程序。]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +567
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +192
   System.Reflection.Assembly.Load(String assemblyString) +35
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +123

[ConfigurationErrorsException: Could not load file or assembly 'System.Data.SQLite' or one of its dependencies. 试图加载格式不正确的程序。]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +11479520
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +484
   System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +79
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +334
   System.Web.Compilation.BuildManager.CallPreStartInitMethods() +280
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1087

[HttpException (0x80004005): Could not load file or assembly 'System.Data.SQLite' or one of its dependencies. 试图加载格式不正确的程序。]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11612256
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141
   System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +11443374

 


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

       出现此问题的原因是System.Data.SQLite.dll 的版本问题,开发环境为x86环境,System.Data.SQLite.dll控件默认为32位,服务器为64位系统,导致兼容性出现问题,无法加载dll文件。

       解决方法:

      在网站应用程序池中,点击“高级设置”-“启用32位应用程序”或者使用64位System.Data.SQLite.dll。

参考资料:

System.Data.SQLite.dll is a mixed assembly, i.e. it contains both managed code and native code. Therefore a particular System.Data.SQLite.dll is either x86 or x64, but never both.

Update (courtesy J. Pablo Fernandez): Cassini, the development web server used by Visual Studio when you press F5 or click the green «play» button, is x86 only which means that even if your workstation is x64, you’ll only be able to use the x86 version of System.Data.SQLite.dll.

An alternative is not to use Cassini but IIS7 which is properly x64.

 

原创文章,转载请注明。本文链接地址: https://www.rootop.org/pages/861.html

作者:Venus

服务器运维与性能优化

发表回复