Reputation: 4302
So... is strange, I have the follow code in my Window
control for setting the window icon, which works prefectly on Win7 machine:
Icon="./Resources/MyWPF.ico"
in
<Window x:Class="MyWPF.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mdi="clr-namespace:WPF.MDI;assembly=WPF.MDI"
xmlns:misc="clr-namespace:MyWPF.Tools.Misc"
xmlns:View="clr-namespace:MyWPF.View"
xmlns:ScriptListView="clr-namespace:MyWPF.Tools.ScriptViewer.View"
Title="Voysus System" WindowStartupLocation="CenterScreen" MinWidth="800" MinHeight="600"
Icon="./Resources/MyWPF.ico"
x:Name="_Root" Closing="_Root_Closing">
But then when it run on Server 2003 Standard x64/ WinXP Pro, both gives me error:
System.Windows.Markup.XamlParseException
Source: PresentationFramework
Message: Cannot convert string './Resources/MyWPF.ico' in attribute 'Icon' to object of type 'System.Windows.Media.ImageSource'. The image decoder cannot decode the image. The image might be corrupted. Error at object '_Root' in markup file 'VoysusSystem;component/mainwindow.xaml' Line 8 Position 95.
StackTrace: at System.Windows.Markup.XamlParseException.ThrowException(String message, Exception innerException, Int32 lineNumber, Int32 linePosition, Uri baseUri, XamlObjectIds currentXamlObjectIds, XamlObjectIds contextXamlObjectIds, Type objectType)
at System.Windows.Markup.XamlParseException.ThrowException(ParserContext parserContext, Int32 lineNumber, Int32 linePosition, String message, Exception innerException)
at System.Windows.Markup.XamlTypeMapper.ParseProperty(Object targetObject, Type propType, String propName, Object dpOrPiOrFi, ITypeDescriptorContext typeContext, ParserContext parserContext, String value, Int16 converterTypeId)
at System.Windows.Markup.BamlRecordReader.ParseProperty(Object element, Type propertyType, String propertyName, Object dpOrPi, String attribValue, Int16 converterTypeId)
at System.Windows.Markup.BamlRecordReader.ReadPropertyRecordBase(String attribValue, Int16 attributeId, Int16 converterTypeId)
at System.Windows.Markup.BamlRecordReader.ReadRecord(BamlRecord bamlRecord)
at System.Windows.Markup.BamlRecordReader.Read(Boolean singleRecord)
at System.Windows.Markup.TreeBuilderBamlTranslator.ParseFragment()
at System.Windows.Markup.TreeBuilder.Parse()
at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
at VoysusSystem.MainWindow.InitializeComponent() in c:\SandBox\MyWPF\MyWPF\MainWindow.xaml:line 1
at VoysusSystem.MainWindow..ctor() in C:\SandBox\MyWPF\MyWPF\MainWindow.xaml.cs:line 93
at VoysusSystem.ViewModel.LoginViewModel.Login(String strPassword) in C:\SandBox\MyWPF\MyWPF\Main\ViewModel\LoginViewModel.cs:line 147
at VoysusSystem.ViewModel.LoginViewModel.<.ctor>b__2(String str) in C:\SandBox\MyWPF\MyWPF\Main\ViewModel\LoginViewModel.cs:line 97
I also tried to use Icon="/MyWPF;component/Resources/MyWPF.ico"
But it also gaves me same error.
After I remove the line, the code stop throwing exception on both WinXP and WinServer2003.
And again, these code is runs fine in Win7 and displayed the icon on the Window properly.
Upvotes: 0
Views: 1407
Reputation: 2516
It happened to me once because used a high def full of color icon, which doesn't seem to be correctly handled by the XP clients. Reduced the number of colors for the icon and it worked.
Upvotes: 2