2012-03-15 109 views
4

我正在嘗試創建一個水晶報告,並且我是該領域的新成員。我從this tutorial post創建了一份水晶報告,但似乎並不奏效。無法加載文件或程序集'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.

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 'log4net' or one of its dependencies. An attempt was made to load a program with an incorrect format.

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 'log4net' could not be loaded.

+0

您是否在計算機上安裝了log4net? – ChrisF 2012-03-15 21:56:39

+0

您的問題是與log4net,而不是水晶報表。你是否添加了對log4net dll的引用? – 2012-03-15 21:57:09

+0

不,我沒有,我不知道該怎麼做,請你幫幫我。謝謝 – emilios 2012-03-15 21:58:49

回答

7

BadFormatImageException是當您的程序編譯爲32位體系結構並嘗試加載64位庫或反之亦然時收到的錯誤。從錯誤中,您可以參考log4net(一個衆所周知的日誌庫)。
首先,檢查什麼樣的你創建你的應用程序(X86,X64 AnyCPU)
,檢查的log4net的位元CPU的(你應該引用您的應用程序相同的位數)
,檢查什麼操作系統IIS正在運行。 (如果是x64和您的應用程序32,請在應用程序池的高級設置部分中將「啓用32位應用程序」設置爲true)

1

「試圖加載程序格式不正確。」可能是因爲你的一些DLL有32位,有些是64位。另一個原因可能是您的應用程序服務器配置爲64位,dll爲32位(或其他方式)。

我會先檢查IIS的設置(這取決於您使用的IIS版本),然後檢查是否將dll編譯爲32位或64位(來自myproject設置)。

相關問題