博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
WPF 在XP系统的兼容问题
阅读量:4623 次
发布时间:2019-06-09

本文共 4646 字,大约阅读时间需要 15 分钟。

BUG 描述:软件在win7下开发,.netframework4.0,在win7下运行无异常,在XP上运行,主窗体正常运行,所有子窗体加载报错

堆栈:

在 System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)

在 System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
在 System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
在 System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
在 System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
在 MCIMerger.PageSort.InitializeComponent()
在 MCIMerger.PageSort..ctor(List`1 ListMixContents, MainForm mainForm, Int32 index)
在 MCIMerger.MainForm.SortOptions_Click(Object sender, RoutedEventArgs e)
在 System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
在 System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
在 System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
在 System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
在 System.Windows.Controls.MenuItem.InvokeClickAfterRender(Object arg)
在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
在 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

InnerException:

System.IO.FileFormatException: 图像格式无法识别。 ---> System.Runtime.InteropServices.COMException: 异常来自 HRESULT:0x88982F07

--- 内部异常堆栈跟踪的结尾 ---
在 System.Windows.Media.PixelFormat.GetPixelFormat(SafeMILHandle bitmapSource)
在 System.Windows.Media.Imaging.BitmapSource.UpdateCachedSettings()
在 System.Windows.Media.Imaging.BitmapSource.set_WicSourceHandle(BitmapSourceSafeMILHandle value)
在 System.Windows.Media.Imaging.BitmapFrameDecode.FinalizeCreation()
在 System.Windows.Media.Imaging.BitmapSource.CompleteDelayedCreation()
在 System.Windows.Media.Imaging.BitmapSource.get_WicSourceHandle()
在 System.Windows.Media.Imaging.BitmapFrameDecode..ctor(Int32 frameNumber, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption, BitmapFrameDecode frameDecode)
在 System.Windows.Media.Imaging.BitmapDecoder.SetupFrames(BitmapDecoder decoder, ReadOnlyCollection`1 frames)
在 System.Windows.Media.Imaging.BitmapDecoder.Initialize(BitmapDecoder decoder)
在 System.Windows.Media.Imaging.BitmapDecoder..ctor(SafeMILHandle decoderHandle, BitmapDecoder decoder, Uri baseUri, Uri uri, Stream stream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption, Boolean insertInDecoderCache, Boolean isOriginalWritable, Stream uriStream, UnmanagedMemoryStream unmanagedMemoryStream, SafeFileHandle safeFilehandle)
在 System.Windows.Media.Imaging.IconBitmapDecoder..ctor(SafeMILHandle decoderHandle, BitmapDecoder decoder, Uri baseUri, Uri uri, Stream stream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption, Boolean insertInDecoderCache, Boolean originalWritable, Stream uriStream, UnmanagedMemoryStream unmanagedMemoryStream, SafeFileHandle safeFilehandle)
在 System.Windows.Media.Imaging.BitmapDecoder.CreateFromUriOrStream(Uri baseUri, Uri uri, Stream stream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption, RequestCachePolicy uriCachePolicy, Boolean insertInDecoderCache)
在 System.Windows.Media.Imaging.BitmapFrame.CreateFromUriOrStream(Uri baseUri, Uri uri, Stream stream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption, RequestCachePolicy uriCachePolicy)
在 System.Windows.Media.ImageSourceConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
在 System.Windows.Baml2006.TypeConverterMarkupExtension.ProvideValue(IServiceProvider serviceProvider)
在 MS.Internal.Xaml.Runtime.ClrObjectRuntime.CallProvideValue(MarkupExtension me, IServiceProvider serviceProvider)

我的解决过程:

1.检查xp上版本 SP3 .NETFramework4.0(其实这一部可以省略,因为在XP下,主窗体是可以运行的)

2.新建一个窗体,在XP上测试时可以加载的,为什么新建的窗体可以运行,而其他的就不行呢?

3.网上查资料,众说纷坛,无果。

4.仔细查看xaml问题,是否在xaml的支持上,xp和win7有不一样的问题的导致的

5.发现了所有加载不了的窗体中 都有Icon="combiner.ico"  检查这个ico,发现有点不规律,目测中间间隔了几个大小

6.记得貌似有资料显示ico过大会造成此BUG?

7.找美工做了一个png,找了个网站自己生成了一个小的,测试 OK。

 

总结:

其实就换一个ico就好了。原来的ico目测是不太规则,可能是因为这个原因,也可能是ico中有一个大小是256*256 ,在xp下加载不出来的原因

总之换了一个 16*16 32*32 的ico,这个问题就解决了

 问题:

在xp下,主窗体和子窗体都用的一个ico,为什么主窗体可以加载,而子窗体不能加载,费解

现在把ico给大家,有知道的麻烦告诉我原因。谢谢(在哪里添加附件啊亲!~)

地址:

 

 

转载于:https://www.cnblogs.com/gaochuan-joey/archive/2012/12/26/2833950.html

你可能感兴趣的文章
Demon_背包系统(实现装备栏,背包栏,可以切换装备)
查看>>
记录:一次数据库被恶意修改配置文件的问题
查看>>
redis 持久化
查看>>
解决Jupyter notebook[import tensorflow as tf]报错
查看>>
Windows平台下使用ffmpeg和segmenter实现m3u8直播点播
查看>>
python网络画图——networkX
查看>>
ubuntu16.04文件形式安装mongodb
查看>>
SpringBoot------ActiveMQ安装
查看>>
详细了解 int? 类型
查看>>
字符串匹配 ?kmp : hash
查看>>
mongod.service: control process exited, code=exited status=1
查看>>
c# 发送邮件、附件 分类: C# 2014-12-...
查看>>
对360来说,江湖上再无“搜狗”这个传说
查看>>
composer
查看>>
OpenCV特征点检测——ORB特征
查看>>
mysql的csv数据导入与导出
查看>>
leetcode笔记:Pascal's Triangle
查看>>
ASP.NET性能优化之构建自定义文件缓存
查看>>
Shell——windows上写完放入linux的时候需要注意的问题
查看>>
65条常用的正则表达式
查看>>