我试图在基于棱镜的WPF应用程序中使用.NET 4 SplashScreen。通过将图像上的构建操作设置为SpashScreen,我使用了SplashScreen。
该应用程序用于继续使用System.Resources.MissingManifestResourceException
进行崩溃。最后,我发现如果我在StartupUri=文件中添加一个MainWindow.xaml“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。所有的事都是在船坞里做的。
那么,我需要手动做些什么,StartupUri才能使SplashScreen正常工作呢?
更新1:完整的异常消息是:
System.Resources.MissingManifestResourceException未被处理 Message=Could找不到适合指定区域性或中性区域性的任何资源。确保"Application.g.resources“在编译时正确嵌入或链接到程序集"Application”中,或者确保所需的所有附属程序集都是可加载和完全签名的。
更新2: --我已经计算出了添加或删除StartupUri并不重要。重要的是,我在App.Resources标记中有一个额外的WPF窗口(不包括App.xaml)或2个虚拟条目。
<Application.Resources>
<Style x:Key="Dummy"/>
<Style x:Key="Dummy1"/>
</Application.Resources>
如果我不这样做,Application.g.resources文件就不会在obj文件中创建,因此也不会嵌入到可执行文件中。添加两个虚拟资源条目是由这个博客帖子提请我注意的。
更新3:
我的问题被鲍伯在MSDN论坛这里上回答了。而且,似乎肯特正试图把我引向同一个方向。
不要将图像的生成操作设置为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“是项目中的一个图像,它的"Build Action”是"Resource“。
发布于 2011-10-16 20:36:18
只需定义您自己的入口点,它首先显示启动屏幕,然后引导棱镜。在项目属性中,将入口点设置为自定义入口点。
internal static class Entry
{
public static void Main(string[] args)
{
var splashScreen = ...;
splashScreen.Show();
var bootstrapper = ...;
bootstrapper....;
}
}
发布于 2013-08-16 06:51:17
请检查下面的附件:http://prismsplashscreen.codeplex.com/有一个完整的棱镜示例
https://stackoverflow.com/questions/7786609
复制相似问题