Hi,
NLog doesn't compile for .Net 4.0 when setting build directive 4_0 after having removed 4_5 directive.
Indeed, NET45 directive is set somewhere whereas another NET4_5 directive exists.
In file AllEventPropertiesLayoutRenderer.cs
#if NET45
if (checkForExclude)
{
// Skip Exclude check when only to exclude CallSiteInformation, and there is none
checkForExclude = !(logEvent.CallSiteInformation == null && Exclude.Count == CallerInformationAttributeNames.Length && Exclude.Contains(CallerInformationAttributeNames[0]));
}
#endif
Should be ?
#if NET4_5
if (checkForExclude)
{
// Skip Exclude check when only to exclude CallSiteInformation, and there is none
checkForExclude = !(logEvent.CallSiteInformation == null && Exclude.Count == CallerInformationAttributeNames.Length && Exclude.Contains(CallerInformationAttributeNames[0]));
}
#endif
Regards
You have very good eyes, and you are correct that it is bug. It has been fixed here:
https://github.com/NLog/NLog/pull/3901
But the code has not yet been merged from master to dev-branch. Still having pending discussions before NLog 4.7.1 can be released, and master can be merged back to dev-branch.
The strange defines NET4_5 and NET4_0 and NET3_5 comes from the days where NLog had a csproj-file for each platform. When changing to the new project-format that allows one to have a single csproj-file, then the defines from Microsoft was not yet ready.
Now with latest version of VS2017 and VS2019 this is no longer the case, and we should probably moved away from using these NLog-specific defines to use the default platform-defines (Without underscore NET45, NET40, NET35 etc.). Another issue to put on the NLog 5.0 milestone :)
@gitjsdr26 I have been thinking to remove NET40 support from NLog, and only support these platforms:
Would removing NET40 be a problem for you? And if so, why can you not use NET35?
@snakefoot , Yes I've good eyes :-) , but this bug raised in front of my eyes when I set this compile directive. This is because I'm using .Net 4.0 to support Windows XP for our customers.
Please, keep this directive 4_0, because I need it and I think that so many people need it for that same reason.
Best regards.
@gitjsdr26 Is there something missing from NET35-build, so you cannot use it?
I need .Net 4.0 because all my others libraries target .Net 4.0 and I'm using async specific .Net 4.0.
I need .Net 4.0 because all my others libraries target .Net 4.0 and I'm using async specific .Net 4.0.
What async specific things do you use in NLog?
Net40-applications has no issue with using Net35-assemblies.
Not for NLog, I'm using Async/Await in my projects from a specific Microsoft Assembly that is compatible with .Net 4.0. That's why I target .Net 4.0.
Sorry, I misunderstood your last remark, could I use NET35 directive for NLog with my project in .Net 4.0 ?
Sorry, I misunderstood your last remark, could I use NET35 directive for NLog with my project in .Net 4.0 ?
NLog compiled with NET3_5 should work just fine with .Net 4.0. You can try the NLog-nuget-package and reference the NLog.dll in the lib/net35 folder (just rename it from .nuget to .zip and open it with you favorite unzipper):
I prefer having the full source project in my projects.
I just tried NET3_5 directive with .Net 4.0 other assemblies and it seems to work.
@gitjsdr26 I have been thinking to remove NET40 support from NLog, and only support these platforms:
- NET35
- NET45
- NET461
- NETSTANDARD13
- NETSTANDARD15
- NETSTANDARD20
Would removing NET40 be a problem for you? And if so, why can you not use NET35?
PS: I think we should drop net35 and netstandard1 also, but not sure if NLog 5 would be too soon for that.
PS: I think we should drop net35 and netstandard1 also, but not sure if NLog 5 would be too soon for that.
Also think that NET35 should stay a little longer. But still think NET40 and SILVERLIGHT and XAMARIN can be removed with NLog 5. And then introduce NET461.
@gitjsdr26 Btw. if you compile your own version of NLog, then I recommend that you take changes from the NLog master-branch and not the dev-branch
@snakefoot , thank you for your recommendation. I've done it and it works.
Thus I'll test the last version.
Closing the issue as resolved by #3901
Most helpful comment
NLog compiled with NET3_5 should work just fine with .Net 4.0. You can try the NLog-nuget-package and reference the NLog.dll in the
lib/net35folder (just rename it from.nugetto.zipand open it with you favorite unzipper):https://www.nuget.org/api/v2/package/NLog/4.7.0