无法创建类型"Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter,Common.Logging.Log4Net" [英] Unable to create type 'Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net'
问题描述
在解决方案中,我有带有其他类库的WCF项目.我为需要记录的项目使用nuget软件包管理器添加了Common.Logging.
I have WCF project with other class libraries in a solution. I added Common.Logging using nuget package manager for projects which require logging.
我收到此错误:
无法创建类型 'Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net'
Unable to create type 'Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net'
当我算命时:
Common.Logging.ILog logger = Common.Logging.LogManager.GetLogger<Service1>();
logger.Error("Test");
我的Web.Config是此处
My Web.Config is here
Bin文件夹具有Common.Logging.Log4net1213.dll和log4net.dll
EDIT : Bin Folder have Common.Logging.Log4net1213.dll as well as log4net.dll
推荐答案
检查是否将Common.Logging.Log4net.dll复制到输出目录.在大多数情况下,缺少dll是因为项目中没有直接引用.
Check if your Common.Logging.Log4net.dll is copied to your output directory. In most cases the dll is missing because there is no direct reference in the project.
在您的配置中,您有:
<logging>
<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net">
<arg key="configType" value="INLINE" />
</factoryAdapter>
</logging>
Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter,Common.Logging.Log4Net->引用不在目录中的Common.Logging.Log4Net.dll.有一个Common.Logging.Log4Net1213.dll dll.因此,您可以将配置更改为:
Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net -> references the Common.Logging.Log4Net.dll which is not in your directory. There is a Common.Logging.Log4Net1213.dll dll. So you can change the config to:
<logging>
<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net1213">
<arg key="configType" value="INLINE" />
</factoryAdapter>
</logging>
或重命名dll
这篇关于无法创建类型"Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter,Common.Logging.Log4Net"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!