无法加载文件或程序集 'log4net' 或其依赖项之一,即使在删除 log4net 之后也是如此
Could not load file or assembly 'log4net' or one of its dependencies, even after removing log4net
我已经完成了另一个问题here and here,但我似乎仍然无法解决这个问题。即使当我尝试从我的程序中删除引用 'log4net' 时,当我 运行 它仍然给出相同的错误。有什么想法吗?
OS 使用:Win 7-64 位。
IDE : Visual Studio 2015
IIS 应用程序池设置:
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.
=== Pre-bind state information ===
LOG: DisplayName = log4net
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: log4net | Domain ID: 10
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///D:/Codes/Apps/Apps/
LOG: Initial PrivatePath = D:\Codes\Apps\Apps\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: D:\Codes\Apps\Apps\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/Apps/6694390a/8e1278d/log4net.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/Apps/6694390a/8e1278d/log4net/log4net.DLL.
LOG: Attempting download of new URL file:///D:/Codes/Apps/Apps/bin/log4net.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.
错误截图
我想要一个允许我使用 log4net
而不是完全删除它的解决方案。
[更新 1]:我尝试使用
的 log4net
C:\Windows\assembly\GAC_32\log4net.2.10.0__692fbea5521e1304\log4net.dll
而不是
C:\Windows\assembly\GAC_64\log4net.2.10.0__692fbea5521e1304\log4net.dll
它似乎有效。但我不明白为什么。我的其他项目正在使用 C:\Windows\assembly\GAC_64\log4net.2.10.0__692fbea5521e1304\log4net.dll
并且它仍然有效。任何人都知道使用 GAC_64
时项目设置的不同之处?
log4net 是否仍在您的 bin 文件夹中?它可能就像从那里删除 dll 一样简单(在从您的代码中删除它之后)。
有时您还必须清理临时 asp.net 文件夹(c:\windows\Microsoft.NET\Frameword\v4.0.30319\Temporary ASP.NET 文件)。
如果这没有帮助,另一个包可能依赖于 log4net。然后你必须识别这个包,如果你想摆脱 log4net,也要删除它。
我通过创建另一个应用程序池解决了这个问题,并将启用 32 位应用程序设置为 "False"。
我已经完成了另一个问题here and here,但我似乎仍然无法解决这个问题。即使当我尝试从我的程序中删除引用 'log4net' 时,当我 运行 它仍然给出相同的错误。有什么想法吗?
OS 使用:Win 7-64 位。
IDE : Visual Studio 2015
IIS 应用程序池设置:
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.
=== Pre-bind state information ===
LOG: DisplayName = log4net
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: log4net | Domain ID: 10
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///D:/Codes/Apps/Apps/
LOG: Initial PrivatePath = D:\Codes\Apps\Apps\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: D:\Codes\Apps\Apps\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/Apps/6694390a/8e1278d/log4net.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/Apps/6694390a/8e1278d/log4net/log4net.DLL.
LOG: Attempting download of new URL file:///D:/Codes/Apps/Apps/bin/log4net.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.
错误截图
我想要一个允许我使用 log4net
而不是完全删除它的解决方案。
[更新 1]:我尝试使用
的 log4netC:\Windows\assembly\GAC_32\log4net.2.10.0__692fbea5521e1304\log4net.dll
而不是
C:\Windows\assembly\GAC_64\log4net.2.10.0__692fbea5521e1304\log4net.dll
它似乎有效。但我不明白为什么。我的其他项目正在使用 C:\Windows\assembly\GAC_64\log4net.2.10.0__692fbea5521e1304\log4net.dll
并且它仍然有效。任何人都知道使用 GAC_64
时项目设置的不同之处?
log4net 是否仍在您的 bin 文件夹中?它可能就像从那里删除 dll 一样简单(在从您的代码中删除它之后)。
有时您还必须清理临时 asp.net 文件夹(c:\windows\Microsoft.NET\Frameword\v4.0.30319\Temporary ASP.NET 文件)。
如果这没有帮助,另一个包可能依赖于 log4net。然后你必须识别这个包,如果你想摆脱 log4net,也要删除它。
我通过创建另一个应用程序池解决了这个问题,并将启用 32 位应用程序设置为 "False"。