Files
velopack/samples/CSharpWpf/Program.cs
T

36 lines
1.1 KiB
C#
Raw Normal View History

2024-03-14 18:37:39 +00:00
using System.Windows;
2024-01-11 14:40:06 +00:00
using Velopack;
namespace CSharpWpf
2024-01-11 14:40:06 +00:00
{
2024-03-14 18:37:39 +00: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.Program</StartupObject>
2024-01-11 14:40:06 +00:00
public class Program
{
public static MemoryLogger Log { get; private set; }
[STAThread]
public static void Main(string[] args)
{
try {
// Logging is essential for debugging! Ideally you should write it to a file.
Log = new MemoryLogger();
// It's important to Run() the VelopackApp as early as possible in app startup.
VelopackApp.Build()
2024-03-14 18:37:39 +00:00
.WithFirstRun((v) => { /* Your first run code here */ })
2024-01-11 14:40:06 +00:00
.Run(Log);
// We can now launch the WPF application as normal.
var app = new App();
app.InitializeComponent();
app.Run();
2024-03-14 18:37:39 +00:00
2024-01-11 14:40:06 +00:00
} catch (Exception ex) {
MessageBox.Show("Unhandled exception: " + ex.ToString());
}
}
}
}