WPF 在XP系統的兼容問題


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給大家,有知道的麻煩告訴我原因。謝謝(在哪里添加附件啊親!~)

地址:http://files.cnblogs.com/gaochuan-joey/combiner.ico

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM