ELMAH 1.2无法加载文件或程序集';System.Data.SQLite';或者它的一个依赖项

ELMAH 1.2无法加载文件或程序集';System.Data.SQLite';或者它的一个依赖项,sqlite,elmah,assembly-loading,Sqlite,Elmah,Assembly Loading,我正在尝试将64位版本的ELMAH 1.2包含到本地托管在IIS Express中的ASP.NET应用程序中。我引用了Elmah.dll的发布版本,以便将其复制到bin文件夹。出于本地工作站配置的目的,我只想记录XML文件的异常。因此,我对ELMAH进行了如下配置: <configuration> <sectionGroup name="elmah"> <section name="errorLog" requirePermission="fa

我正在尝试将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>
[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

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

这不是ELMAH或SQLite的问题,问题是IISExpress在桌面上以32位运行。你需要为你的桌面运行32位,64位应该可以用于生产

看看这个:,特别是:

32位和64位系统都受支持,但是只有32位版本的IIS 7.5 Express存在


解决方法是不引用Elmah部件。当我这样做时,我没有得到问题中描述的运行时异常。唯一的问题是,我无法使用信号功能或在global.asax中捕获ErrorLog_Logged事件,如中所述。是的,我知道,谢谢。我的问题仍然是:为什么CLR试图加载一个不需要的程序集?很抱歉误读了您的问题,您的问题看起来与我也遇到过的问题类似,因为IISExpress没有加载DLL,因为它是64位的。不幸的是,我不知道如何回答你的问题。