我想在基於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我已經更新了這個問題。 –