Hi,
I'm currently unable to use version 4.6.7 of NLog.
Steps to replicate issue:
Create 2 projects in Visual studio
Project B targets .net standard 2.0 and is using version 4.6.7 of NLog added through nuget.
Project A targets .net framework 4.7.2, references project B and tries to use a class from project B that uses NLog.
Results in the following error:
However, if i manually had the reference to project B using the NLog.dll at "C:\Users\User.nuget\packages\nlog\4.6.7\lib\netstandard2.0" then it works without issue.
Current NLog config C#
```C#
public class LogService : ILogService
{
private static Logger logger = LogManager.GetLogger("Log");
public LogService()
{
// Step 1. Create configuration object
var config = new NLog.Config.LoggingConfiguration();
// Step 2. Create targets
var fileTarget = new NLog.Targets.FileTarget("Target1")
{
Layout = "${longdate} Level: ${level:upperCase=true} Message: ${message} ${exception}",
FileName = "C:\\Logs\\Log.txt",
CreateDirs = true,
};
config.AddTarget(fileTarget);
// Step 3. Define rules
config.AddRule(LogLevel.Debug, LogLevel.Fatal, fileTarget);
// Step 4. Activate the configuration
LogManager.Configuration = config;
}
public void WriteDebugMessage(string message)
{
logger.Debug(message);
}
public void WriteErrorMessage(string message)
{
logger.Error(message);
}
public void WriteInfoMessage(string message)
{
logger.Info(message);
}
}
```
Hi! Thanks for opening your first issue here! Please make sure to follow the issue template - so we could help you better!
What happens if you call NLog (no need to add NLog as project reference) in your start project?
When mixing NetFramework with NetCore-projects then one should make sure to use this in the NetFramework-csproj:
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
See also: https://www.hanselman.com/blog/ReferencingNETStandardAssembliesFromBothNETCoreAndNETFramework.aspx
When mixing NetFramework with NetCore-projects then one should make sure to use this in the NetFramework-csproj:
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>See also: https://www.hanselman.com/blog/ReferencingNETStandardAssembliesFromBothNETCoreAndNETFramework.aspx
Thank you! This solved the problem :)
Most helpful comment
When mixing NetFramework with NetCore-projects then one should make sure to use this in the NetFramework-csproj:
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>See also: https://www.hanselman.com/blog/ReferencingNETStandardAssembliesFromBothNETCoreAndNETFramework.aspx