ELMAH 1.2 无法加载文件或程序集“System.Data.SQLite”;或其依赖项之一

发布于 2024-12-10 23:33:57 字数 3933 浏览 0 评论 0原文

我正在尝试将 64 位版本的 ELMAH 1.2 包含到本地托管在 IIS Express 中的 ASP.NET 应用程序中。我引用了 Elmah.dll 的发行版本,以便将其复制到 bin 文件夹中。出于本地工作站配置的目的,我只想将异常记录到 XML 文件。因此,我按如下方式配置 ELMAH:

<configuration>
    <sectionGroup name="elmah">
       <section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
    </sectionGroup>

    <elmah>
       <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="C:\Logs\Elmah" />
    </elmah>

    <system.webServer>
       <handlers>
          <add name="Elmah" path="elmah.axd" verb="POST,GET,HEAD" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" />
       </handlers>
       <modules>
          <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
       </modules>
    </system.webServer>
</configuration>

当我从 Visual Studio 启动调试会话时,站点会加载并出现以下运行时错误:

无法加载文件或程序集“System.Data.SQLite”或一个它的依赖项。尝试加载格式不正确的程序。

堆栈跟踪如下所示:

[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) +60
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +555
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +308
System.Reflection.Assembly.Load(String assemblyString) +51
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +115

[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) +1031
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +346
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +85
System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +54
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +274
System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +64
System.Web.Compilation.BuildManager.CallPreStartInitMethods() +235
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1107

[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) +763
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +156
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +243

问题是,为什么 ELMAH 会导致运行时尝试加载 System.Data.SQLite,因为我不想使用SQLite 用于记录异常?另外,我该如何解决这个问题(我已经在 ELMAH google group 和 StackOverflow 上到处查看了)?

I am trying to include the 64-bit version of ELMAH 1.2 into an ASP.NET application that is hosted locally in IIS Express. I referenced the release version of Elmah.dll so that it would copy to the bin folder. For local workstation configuration purposes, I only want to log exceptions to XML files. As a result, I configured ELMAH as follows:

<configuration>
    <sectionGroup name="elmah">
       <section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
    </sectionGroup>

    <elmah>
       <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="C:\Logs\Elmah" />
    </elmah>

    <system.webServer>
       <handlers>
          <add name="Elmah" path="elmah.axd" verb="POST,GET,HEAD" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" />
       </handlers>
       <modules>
          <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
       </modules>
    </system.webServer>
</configuration>

When I start a debugging session from Visual Studio, the site loads up and I get the following runtime error:

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.

The stack trace looks as follows:

[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) +60
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +555
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +308
System.Reflection.Assembly.Load(String assemblyString) +51
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +115

[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) +1031
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +346
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +85
System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +54
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +274
System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +64
System.Web.Compilation.BuildManager.CallPreStartInitMethods() +235
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1107

[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) +763
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +156
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +243

The question is, why would ELMAH cause the runtime to try to load System.Data.SQLite since I do not want to use SQLite for logging the exception? Also, how can I resolve this issue (I looked everywhere on the ELMAH google group and on StackOverflow already)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

终遇你 2024-12-17 23:33:57

这不是 Elmah 或 SQLite 的问题,问题是 IISExpress 在桌面上以 32 位运行。您的桌面需要运行 32 位,64 位应该适合生产。

看看这个:http://learn.iis.net/ page.aspx/1010/iis-75-express-readme/,特别是:

同时支持 32 位和 64 位系统,但仅存在 IIS 7.5 Express 的 32 位版本。

It's not an issue with Elmah or SQLite, the problem is that IISExpress runs in 32 bit on your desktop. You'll need to run 32bit for your desktop, 64bit should be fine for production.

Check out this: http://learn.iis.net/page.aspx/1010/iis-75-express-readme/, especially:

Both 32-bit and 64-bit systems are supported, however only a 32-bit build of IIS 7.5 Express exists.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文