繁体   English   中英

如何修复 CS1503 参数 1:无法从“字符串”转换为“System.Type”?

[英]How to fix CS1503 Argument 1: cannot convert from 'string' to 'System.Type'?

我在 .net 框架 class 库项目中有这段代码,我想在.net 标准 class 库项目中重用它。 它按预期工作,但在 .net 标准项目中出现编译错误。

public FxLogger(string logger)
{
    ILog AppLogger = LogManager.GetLogger(logger);

错误:

CS1503  Argument 1: cannot convert from 'string' to 'System.Type'

两个应用程序中的 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);

尝试

 ILog AppLogger = LogManager.GetLogger(Assembly.GetCallingAssembly(),logger);

看起来 .net 框架方法定义为

public static ILog GetLogger(string name)
{
    return GetLogger(Assembly.GetCallingAssembly(), name);
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM