question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NLog randomly crashes in UWP app with Microsoft.Extensions.DependencyInjection (only when debugging)

See original GitHub issue

NLog version: 4.6.7

Platform: UWP: Windows 10, version 1809(10.0; Build 17763) - Windows 10, version 1903(10.0; Build 18362) Console: .NET Core 2.2

Current NLog config (xml or C#, if relevant)

public static void AddLogger(this ServiceCollection services)
        {
            services.AddLogging(loggingBuilder =>
            {
                // configure Logging with NLog
                loggingBuilder.ClearProviders();
                loggingBuilder.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
                loggingBuilder.AddNLog();
            });

            // UWP is very restrictive of where you can save files on the disk.
            // The preferred place to do that is app's local folder.
            StorageFolder folder = ApplicationData.Current.LocalFolder;
            string fullPath = folder.Path + @"\Logs\${date:format=yyyy-MM-dd}.Player.log";

            var config = new LoggingConfiguration();
            var fileTarget = new FileTarget("App.log")
            {
                FileName = fullPath,
                Layout = "${longdate} ${uppercase:${level}} ${message} ${exception}"
            };
            config.AddTarget(fileTarget);
            config.AddRule(NLog.LogLevel.Debug, NLog.LogLevel.Fatal, "App.log");

            LogManager.Configuration = config;
        }
  • What is the current result? Sometimes it’s working. But sometimes UWP app is crashing. So random crash. With no trace, but I know it’s because of nlog. crash
  • What is the expected result? Stable working app.
  • Did you checked the Internal log? No.
  • Please post full exception details (message, stacktrace, inner exceptions) I’ve created a minimal reproducible example here: https://github.com/aosyatnik/UWP_with_nLog
  • Are there any workarounds? yes/no I don’t know.
  • Is there a version in which it did work? I don’t think so.
  • Can you help us by writing an unit test? Maybe.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:18 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
304NotModifiedcommented, Oct 11, 2019

So there is no logging enabled or whatsoever and it still crashes (sometimes)

error details until now:

System.ExecutionEngineException
  HResult=0x80131506
  Source=<Cannot evaluate the exception source>
  StackTrace:
<Cannot evaluate the exception stack trace>

it’s always 0x80131506

maybe related: https://developercommunity.visualstudio.com/content/problem/25274/systemexecutionengineexception-when-debugging.html

Read more comments on GitHub >

github_iconTop Results From Across the Web

UWP app random crash - Microsoft Q&A
Our UWP app crashes in release mode randomly. Windows event viewer shows following exception codes. Faulting module name: edgeIso.dll, ...
Read more >
UWP/C# app crashes on startup when in "Release" from ...
UWP /C# app crashes on startup when in "Release" from Visual Studio, runs fine in Debug. Hi,. I've programmed a simple timer app...
Read more >
UWP | XAML Brewer, by Diederik Krols
In this article we describe the process of migrating a user control from UWP to WinUI 3. The subject is the Radial Gauge...
Read more >
Xamarin Archives - MSCTEK
So, I created two new apps in AppCenter, one for iOS and another for Android. AppCenter also works with Xamarin UWP and a...
Read more >
What's New in NDepend
From NDepend to ILSpy: Just right click any assembly, namespace, class, method or field in NDepend or Visual Studio (with the NDepend extension...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found