与Costura Fody一起使用Nlog时如何解决错误

问题描述 投票:2回答:1

我正在使用Nlog,最近决定使用Fody / Costura将我的DLL嵌入到最终的可执行文件中。我注意到在使用下面推荐的实例声明启动和创建Logger时,我在调用GetCurrentClassLogger时遇到异常(请参阅下面的例外)。如果我卸载Costura / Fody,那么例外就会消失。 Nlog会消耗错误,但每次启动我的代码时都会破坏该错误,我想解决它。

//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,它可能在其他代码中发生。

c# nlog fody-costura
1个回答
1
投票

创建了github.com/NLog/NLog/pull/3258 - Rolf Kristensen

因此将在NLog 4.6.1中修复。今天或明天发布(取决于时区;)

更新:它发布了:https://www.nuget.org/packages/NLog/4.6.1

© www.soinside.com 2019 - 2024. All rights reserved.