-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
56 lines (51 loc) · 2.08 KB
/
Copy pathProgram.cs
File metadata and controls
56 lines (51 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using Avalonia;
using NLog;
namespace NetScanner;
internal static class Program
{
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
// Wichtig: Initialisierung NICHT vor AppMain anfassen (Avalonia-Vorgabe).
[STAThread]
public static void Main(string[] args)
{
// Globale Sicherheitsnetze: nichts soll den Prozess ungeloggt beenden. Gerade
// bei viel Netzwerk-I/O und nativem Interop (libvlc) ist das die wichtigste Lücke.
AppDomain.CurrentDomain.UnhandledException += (_, e) =>
{
Log.Fatal(e.ExceptionObject as Exception,
"Unbehandelte Ausnahme (terminating={Term})", e.IsTerminating);
LogManager.Flush();
};
TaskScheduler.UnobservedTaskException += (_, e) =>
{
Log.Error(e.Exception, "Unbeobachtete Task-Ausnahme");
e.SetObserved(); // markiert die Exception als behandelt
};
try
{
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
}
catch (Exception ex)
{
// Fataler Startfehler (z. B. Avalonia-Backend, fehlende Anzeige): loggen und
// sichtbar abbrechen, statt ohne Spur zu verschwinden.
Log.Fatal(ex, "Anwendung mit Ausnahme beendet");
throw;
}
finally
{
LogManager.Shutdown();
}
}
public static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure<App>()
.UsePlatformDetect()
.WithInterFont()
// Nur die fuer die Entwicklung nuetzlichen Avalonia-Log-Bereiche ins Trace-Output:
// Binding-Fehler (MVVM), Layout- und Property-Warnungen. Das rauschige [Control]/
// [Visual]-Framework-Logging (z. B. "PlatformImpl is null" beim Fensterschliessen)
// bleibt damit aussen vor. Ohne Argumente wuerde LogToTrace() alle Bereiche loggen.
.LogToTrace(Avalonia.Logging.LogEventLevel.Warning,
Avalonia.Logging.LogArea.Binding,
Avalonia.Logging.LogArea.Layout,
Avalonia.Logging.LogArea.Property);
}