简体   繁体   English

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

[英]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.

相关问题 CS1503 参数 1:无法从 'string' 转换为 'string[*,*]' - CS1503 Argument1: cannot convert from 'string' to 'string[*,*]' CS1503 C# 参数 1:无法从“字符串”转换为“System.Data.SqlClient.SqlCommand” - CS1503 C# Argument 1: cannot convert from 'string' to 'System.Data.SqlClient.SqlCommand' 将文本复制到剪贴板错误CS1503参数2:无法从'string'转换为'System.Windows.Forms.TextDataFormat' - Copying text to clipboard Error CS1503 Argument 2: cannot convert from 'string' to 'System.Windows.Forms.TextDataFormat' CS1503:参数 2:无法从 'System.Action[*,*,*] 转换为 System.Action[]' C# 2022 - CS1503: Argument 2: Cannot convert from 'System.Action[*,*,*] to System.Action[]' C# 2022 出现错误 CS1503:“参数 1:无法从 'System.Diagnostics,PerformanceCounter' 转换为 'int' - Getting Error CS1503: "Argument 1: Cannot convert from 'System.Diagnostics,PerformanceCounter' to 'int' CS1503 C#参数1:无法从“ System.IO.Stream”转换为“ char []” - CS1503 C# Argument 1: cannot convert from 'System.IO.Stream' to 'char[]' 错误 CS1503:参数 1:无法从“UnityEngine.XR.XRNode”转换为“string” - error CS1503: Argument 1: cannot convert from 'UnityEngine.XR.XRNode' to 'string C# 错误 CS1503 参数 1:无法从“字符串”转换为“字符” - C# Error CS1503 Argument 1: cannot convert from 'string' to 'Character' C# - CS1503 - 参数 1:无法从“字符串”转换为“整数” - C# - CS1503 - Argument 1: cannot convert from 'string' to 'int' 如何解决此错误“错误 CS1503:参数 1:无法从‘void’转换为‘bool’” - How to resolve this error "error CS1503: Argument 1: cannot convert from 'void' to 'bool'"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM