[英]How to fix CS1503 Argument 1: cannot convert from 'string' to 'System.Type'?
I have this piece of code in .net framework class library project, I want to reuse it in.net standard class library project.我在 .net 框架 class 库项目中有这段代码,我想在.net 标准 class 库项目中重用它。 It works as expected, but gives compilation error in .net standard project.
它按预期工作,但在 .net 标准项目中出现编译错误。
public FxLogger(string logger)
{
ILog AppLogger = LogManager.GetLogger(logger);
Error:错误:
CS1503 Argument 1: cannot convert from 'string' to 'System.Type'
log4net version in both application 2.0.8 I can see these methods declaration in the LogManager
class两个应用程序中的 log4net 版本 2.0.8 我可以在
LogManager
class 中看到这些方法声明
public static ILog GetLogger(string repository, string name);
public static ILog GetLogger(Assembly repositoryAssembly, Type type);
public static ILog GetLogger(string repository, Type type);
public static ILog GetLogger(Type type);
public static ILog GetLogger(Assembly repositoryAssembly, string name);
Try尝试
ILog AppLogger = LogManager.GetLogger(Assembly.GetCallingAssembly(),logger);
It looks like the .net framework method is defined as看起来 .net 框架方法定义为
public static ILog GetLogger(string name)
{
return GetLogger(Assembly.GetCallingAssembly(), name);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.