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给大家,有知道的麻烦告诉我原因。谢谢(在哪里添加附件啊亲!~)
地址: