如何修复CS1503参数1:无法从'string'转换为"系统类型"?



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

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

错误:

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

两个应用程序2.0.8中的log4net版本我可以在LogManager类中看到这些方法声明

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);
}

最新更新