{"id":1905,"date":"2022-08-30T15:20:25","date_gmt":"2022-08-30T15:20:25","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/12\/02\/could-not-load-file-or-assembly-system-data-sqlite-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:20:25","modified_gmt":"2022-08-30T15:20:25","slug":"could-not-load-file-or-assembly-system-data-sqlite-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/could-not-load-file-or-assembly-system-data-sqlite-collection-of-common-programming-errors\/","title":{"rendered":"Could not load file or assembly &#39;System.Data.SQLite&#39;-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;ve installed ELMAH 1.1 .Net 3.5 x64 in my ASP.NET project and now I&#8217;m getting this error (whenever I try to see any page):<\/p>\n<blockquote>\n<p>Could not load file or assembly &#8216;System.Data.SQLite, Version=1.0.61.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139&#8217; or one of its dependencies. An attempt was made to load a program with an incorrect format.<\/p>\n<p>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.<\/p>\n<p>Exception Details: System.BadImageFormatException: Could not load file or assembly &#8216;System.Data.SQLite, Version=1.0.61.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139&#8217; or one of its dependencies. An attempt was made to load a program with an incorrect format.<\/p>\n<\/blockquote>\n<p>More error details at the bottom.<\/p>\n<p>My Active Solution platform is &#8220;Any CPU&#8221; and I&#8217;m running on a x64 Windows 7 on an x64, of course, processor. The reason why we are using this version of ELMAH is because 1.0 .Net 3.5 (x86, which is the only platform for which it&#8217;s compiled) gave us this same error on our x64 Windows server.<\/p>\n<p>I&#8217;ve tried compiling for x86 and x64 and I get the same error. I&#8217;ve tried removing the all compiler output (bin and obj). Finally I&#8217;ve made a reference to the SQLite dll directly, something that was not needed for the project to work on the server and I&#8217;ve got this compiler error:<\/p>\n<blockquote>\n<p>Error 1 Warning as Error: Assembly generation &#8212; Referenced assembly &#8216;System.Data.SQLite.dll&#8217; targets a different processor MyProject<\/p>\n<\/blockquote>\n<p>Any ideas what the problem might be?<\/p>\n<blockquote>\n<p>Source Error:<\/p>\n<p>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.<\/p>\n<p>Stack Trace:<\/p>\n<p>[BadImageFormatException: Could not load file or assembly &#8216;System.Data.SQLite, Version=1.0.61.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139&#8217; or one of its dependencies. An attempt was made to load a program with an incorrect format.] System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark&amp; stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0 System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark&amp; stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +43 System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark&amp; stackMark, Boolean forIntrospection) +127 System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark&amp; stackMark, Boolean forIntrospection) +142 System.Reflection.Assembly.Load(String assemblyString) +28<\/p>\n<p>System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +46<\/p>\n<p>[ConfigurationErrorsException: Could not load file or assembly &#8216;System.Data.SQLite, Version=1.0.61.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139&#8217; 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) +613 System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +203 System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +105 System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178 System.Web.Compilation.BuildProvidersCompiler..ctor(VirtualPath configPath, Boolean supportLocalization, String outputAssemblyName) +54 System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean isPrecompiledApp) +232<\/p>\n<p>System.Web.Compilation.BuildManager.CompileGlobalAsax() +52 System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +337<\/p>\n<p>[HttpException (0x80004005): Could not load file or assembly &#8216;System.Data.SQLite, Version=1.0.61.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139&#8217; or one of its dependencies. An attempt was made to load a program with an incorrect format.]<br \/>\nSystem.Web.Compilation.BuildManager.ReportTopLevelCompilationException() +58 System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +512 System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters) +729<\/p>\n<p>[HttpException (0x80004005): Could not load file or assembly &#8216;System.Data.SQLite, Version=1.0.61.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139&#8217; or one of its dependencies. An attempt was made to load a program with an incorrect format.] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +8896783 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +85<\/p>\n<p>System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +259<\/p>\n<\/blockquote>\n<p id=\"rop\"><small>Originally posted 2013-12-02 21:17:04. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve installed ELMAH 1.1 .Net 3.5 x64 in my ASP.NET project and now I&#8217;m getting this error (whenever I try to see any page): Could not load file or assembly &#8216;System.Data.SQLite, Version=1.0.61.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139&#8217; or one of its dependencies. An attempt was made to load a program with an incorrect format. Description: An unhandled exception [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1905","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1905","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1905"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1905\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1905"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1905"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1905"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}