C# 如何解决将Nlog与Costura Fody一起使用时出现的错误
我正在使用Nlog,最近决定使用Fody/Costura将我的DLL嵌入到最终的可执行文件中。我注意到,在使用下面推荐的实例声明启动和创建记录器时,调用GetCurrentClassLogger时出现异常(请参见下面的异常)。如果我卸载Costura/Fody,异常就会消失。Nlog会消耗错误,但每次我启动代码时,它都会在该错误上中断,我想解决它C# 如何解决将Nlog与Costura Fody一起使用时出现的错误,c#,nlog,fody-costura,C#,Nlog,Fody Costura,我正在使用Nlog,最近决定使用Fody/Costura将我的DLL嵌入到最终的可执行文件中。我注意到,在使用下面推荐的实例声明启动和创建记录器时,调用GetCurrentClassLogger时出现异常(请参见下面的异常)。如果我卸载Costura/Fody,异常就会消失。Nlog会消耗错误,但每次我启动代码时,它都会在该错误上中断,我想解决它 //recommended logger declaration private static Logger logger = LogManager.
//recommended logger declaration
private static Logger logger = LogManager.GetCurrentClassLogger();
//exception thrown when calling the instance declaration
Error Error logging version of assembly NLog, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=5120e14c03d0593c. Exception:
System.ArgumentException: The path is not of a legal form.
at System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck,
Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.GetFullPathInternal(String path)
at System.IO.Path.GetFullPath(String path)
at System.Diagnostics.FileVersionInfo.GetFullPathWithAssert(String
fileName)
at System.Diagnostics.FileVersionInfo.GetVersionInfo(String fileName)
at NLog.Common.InternalLogger.LogAssemblyVersion(Assembly assembly)
我已经验证,如果没有安装Fody/Costura,错误会消失,当安装Fody/Costura时,错误会返回
我希望解决这个错误,而不是每次运行代码时都让IDE停止。我也不想忽略特定的异常,以防它发生在与Nlog无关的其他代码中。引发的异常是System.ArgumentException,它可能发生在其他代码中
创建github.com/NLog/NLog/pull/3258–Rolf Kristensen
因此将在NLog 4.6.1中固定。今天或明天发布(取决于时区;)
更新:发布:创建的NLog 4.6.1现在发布: