NLog: Doesn't compile for .Net 4.0 when setting build directive 4_0.

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

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (9 by maintainers)

Most upvoted comments

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):

https://www.nuget.org/api/v2/package/NLog/4.7.0

@snakefoot , thank you for your recommendation. I’ve done it and it works. Thus I’ll test the last version.

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.