Reputation: 25
I upgraded my project to dotnetcore 2.1. After doing that when I try to run it I am getting a System.MissingMethodException
The error in full detail is
'Method not found: 'NLog.LogFactory NLog.LogManager.LoadConfiguration(System.String)'.'
I have already tried downgrading the NLog but it didn't work and it affected by other dependencies.
Here is my web.config file
<?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>
Here is my NLog.config file
<?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>
Any help would be great.
Upvotes: 1
Views: 4433
Reputation: 36750
The missing method exception will araise in NLog when mixing incompatible versions, e.g. multiple versions of NLog in one project (when not using the GAC), or mixing major versions (v3 and v4).
NLog is using Semantic Versioning (see https://semver.org/), that means:
PS: no need for <dependentAssembly>
in the first two cases.
Upvotes: 3