我有一个WPF .NET 4应用程序,我重写该OnStartup
方法,以处理传递给我的应用程序的文件.但是,似乎在应用程序运行时不会调用此方法.我在那里放了一个例外,甚至是一个断点,它启动并完全忽略了这一点.
我错过了什么吗?
App.xml.cs的代码:
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
throw new NotImplementedException();
}
}
Run Code Online (Sandbox Code Playgroud)
App.xaml的内容:
<Application x:Class="XGN_Image_Downloader.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>
Run Code Online (Sandbox Code Playgroud)
编辑:找到它!App.xaml中的x:Class属性与App.xaml.cs类不匹配:)这就是你在喝葡萄酒时编码的结果.(感谢这个帖子:WPF app启动问题)