我想在基于Prism的WPF应用程序中使用.NET 4 SplashScreen。我通过将图像上的构建动作设置为SplashScreen来使用SpashScreen。如何在基于WPF Prism的应用程序中使用.NET 4 SplashScreen?
该应用程序用于继续与System.Resources.MissingManifestResourceException
一起崩溃。最后我发现,如果我在App.Xaml文件中添加StartupUri =“MainWindow.xaml”,则SplashScreen可以正常工作。
<Application x:Class="Application"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
</Application>
但是在棱镜应用中,我们不能有StartupUri。一切都在Bootstrapper中完成。
那么我需要做些什么来让StartupUri能够使SplashScreen工作?
更新1:完整的异常消息为:
System.Resources.MissingManifestResourceException了未处理
消息=找不到适合于指定培养或中性培养的任何资源。在编译时确保 “Application.g.resources”已正确嵌入或链接到 程序集“应用程序”,或者所有需要的卫星 程序集均可加载并完全签名。
更新2: 我已想出了添加或删除的StartupUri无所谓。重要的是我有一个额外的WPF窗口(App.xaml除外)或App.Resources标签中的2个虚拟条目。
<Application.Resources>
<Style x:Key="Dummy"/>
<Style x:Key="Dummy1"/>
</Application.Resources>
如果我不这样做,是不是在OBJ文件中创建的文件Application.g.resources,因此没有嵌入可执行文件。 这个blog post引起了我的注意,添加了两个虚拟资源条目。
更新3:
我的问题是关于MSDN论坛here回答鲍勃宝。此外,肯特似乎试图指出我在同一个方向。
不要将图像的构建操作设置为SplashScreen。相反:
在App OnStartup方法添加代码:
protected override void OnStartup(StartupEventArgs e)
{
SplashScreen splashScreen = new SplashScreen("splashscreen.png");
splashScreen.Show(true);
base.OnStartup(e);
Bootstrapper bootstrapper = new Bootstrapper();
bootstrapper.Run();
}
“splashscreen.png” 是项目中的一个图像,而其 “生成操作” 是“资源”。
一个完整的例子就是在那里某处这里的一个问题? – DeCaf
@DeCaf我已经更新了这个问题。 –