我将项目升级到dotnetcore 2.1。完成此操作后,当我尝试运行它时,我得到了System.MissingMethodException
详细错误为
'Method not found: 'NLog.LogFactory NLog.LogManager.LoadConfiguration(System.String)'.'
我已经尝试降级NLog,但是它不起作用,并且受到其他依赖项的影响。
这是我的web.config文件
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" forwardWindowsAuthToken="false" stdoutLogEnabled="false">
<environmentVariables />
</aspNetCore>
</system.webServer>
</configuration>
这是我的NLog.config文件
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogLevel="Warn"
internalLogFile="c:\temp\internal-IEPAPI-nlog.txt">
<extensions>
<add assembly="NLog.Web.AspNetCore"/>
</extensions>
<!-- define various log targets -->
<targets>
<!-- write logs to file -->
<!--target xsi:type="File" name="allfile" fileName="c:\temp\nlog-all-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId.Id}|${logger}|${uppercase:${level}}|${message} ${exception}" /-->
<target xsi:type="File" name="InvoiceEngineProcessApiLogFile" fileName="D:\Logs\BillingEngine\ProcessApis\InvoiceEngine-${shortdate}.log"
layout="${longdate}|TraceId=${aspnet-traceidentifier}|${event-properties:item=EventId.Id}|${logger}|${uppercase:${level}}| ${message} ${exception:format = ToString,StackTrace}${newline}" />
<target xsi:type="Null" name="blackhole" />
</targets>
<rules>
<!--All logs, including from Microsoft-->
<!--logger name="*" minlevel="Trace" writeTo="allfile" /-->
<!--Skip Microsoft logs and so log only own logs-->
<!--<logger name="Microsoft.*" minlevel="Trace" writeTo="InvoiceEngineProcessApiLogFile" />-->
<logger name="*" minlevel="Trace" writeTo="InvoiceEngineProcessApiLogFile" >
<filters>
<when condition="(LogLevel.Debug >= level) and equals('${var:debugLoggingEnabled}', '0')" action="Ignore" />
</filters>
</logger>
</rules>
</nlog>
任何帮助都会很棒。
答案 0 :(得分:0)
当混合不兼容的版本时,例如在NLog中,缺少的方法异常将在NLog中引起。一个项目中有多个版本的NLog(不使用GAC时),或者是主要版本(v3和v4)混合在一起。
NLog正在使用语义版本控制(请参阅https://semver.org/),这意味着:
PS:在前两种情况下不需要<dependentAssembly>
。