2024-02-02 12:35:57 +00:00
|
|
|
using System.Windows;
|
2024-11-20 22:19:39 -08:00
|
|
|
using Velopack;
|
2024-01-11 14:40:06 +00:00
|
|
|
|
2024-08-06 22:56:40 +01:00
|
|
|
namespace CSharpWpf
|
2024-01-11 14:40:06 +00:00
|
|
|
{
|
|
|
|
|
public partial class App : Application
|
|
|
|
|
{
|
2025-03-12 22:02:47 +00:00
|
|
|
public static MemoryLogger Log { get; private set; } = new();
|
|
|
|
|
|
2024-11-20 22:19:39 -08:00
|
|
|
// Since WPF has an "automatic" Program.Main, we need to create our own.
|
|
|
|
|
// In order for this to work, you must also add the following to your .csproj:
|
|
|
|
|
// <StartupObject>CSharpWpf.App</StartupObject>
|
|
|
|
|
[STAThread]
|
|
|
|
|
private static void Main(string[] args)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
// It's important to Run() the VelopackApp as early as possible in app startup.
|
|
|
|
|
VelopackApp.Build()
|
2025-03-03 21:57:57 +00:00
|
|
|
.OnFirstRun((v) => { /* Your first run code here */ })
|
2025-03-12 22:02:47 +00:00
|
|
|
.SetLogger(Log)
|
2025-03-03 21:57:57 +00:00
|
|
|
.Run();
|
2024-11-20 22:19:39 -08:00
|
|
|
|
|
|
|
|
// We can now launch the WPF application as normal.
|
|
|
|
|
var app = new App();
|
|
|
|
|
app.InitializeComponent();
|
|
|
|
|
app.Run();
|
|
|
|
|
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
MessageBox.Show("Unhandled exception: " + ex.ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-01-11 14:40:06 +00:00
|
|
|
}
|
|
|
|
|
}
|