无法加载文件或程序集"log4net"或其依赖项之一 [英] Could not load file or assembly 'log4net' or one of its dependencies

查看:457
本文介绍了无法加载文件或程序集"log4net"或其依赖项之一的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一份水晶报表,而我是该领域的新手.我已经从此教程帖子,但似乎不起作用.

I am trying to create a crystal report and I am new to that field. I have created a crystal report from this tutorial post but it does not seems to work.

我的错误是:

无法加载文件或程序集'log4net'或其依赖项之一.试图加载格式错误的程序.

Could not load file or assembly 'log4net' or one of its dependencies. An attempt was made to load a program with an incorrect format.

描述:当前Web请求的执行过程中发生未处理的异常.请查看堆栈跟踪,以获取有关错误及其在代码中起源的更多信息.

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.

异常详细信息:System.BadImageFormatException:无法加载文件或程序集'log4net'或其依赖项之一.试图加载格式错误的程序.

Exception Details: System.BadImageFormatException: Could not load file or assembly 'log4net' or one of its dependencies. An attempt was made to load a program with an incorrect format.

源错误:

在执行当前Web请求期间生成了未处理的异常.可以使用下面的异常堆栈跟踪来标识有关异常的来源和位置的信息.

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.

程序集加载跟踪:以下信息有助于确定为什么无法加载程序集"log4net".

Assembly Load Trace: The following information can be helpful to determine why the assembly 'log4net' could not be loaded.

推荐答案

BadFormatImageException 是在为32位体系结构编译程序并尝试加载64位库时收到的错误,反之亦然.从该错误中,您可以引用log4net(一个众所周知的日志库).
首先,检查您正在创建应用程序的CPU类型(x86,x64,AnyCPU)
第二,检查log4net的位数(您应该引用应用程序的位数)
第三,检查正在运行的操作系统IIS. (如果是x64,而您的应用是32,则在应用程序池的高级设置"部分中将启用32位应用程序"设置为true)

BadFormatImageException is the error that you receive when your program is compiled for a 32bit architecture and will try to load a 64bit library or viceversa. From the error, you have a reference to log4net (a well known log library).
First, check for what kind of CPU you are creating your application (x86, x64, AnyCPU)
Second, check the bitness of log4net (You should reference the same bitness of your apps)
Third, check on what OS IIS is running. (if is x64 and your app 32, set 'Enable 32-bit Applications' to true in the advanced settings section of the application pool)

这篇关于无法加载文件或程序集"log4net"或其依赖项之一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆