I am trying to use an Icon in my WPF application, and some images for other things, but I keep getting errors from the Designer View saying stuff like "path-x is not a valid resource or cannot be found." - where "path-x" is the path of whatever image I am trying to use.
If it were looking in the right place, I bet it'd find it ;)
BUT, then, it decided to not give me that error anymore. So, I went ahead and clicked Run (F5), to see my new Icon in the title bar. Only to be confronted with this beast:
"System.Windows.Markup.XamlParseException occurred Message='Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' Line number '5' and line position '50'.
Source=PresentationFramework
LineNumber=5 LinePosition=50
StackTrace: at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri) at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri) at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri) at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream) at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator) at One_Stop_Management.MainWindow.InitializeComponent() in c:\Users\Jason\Documents\Visual Studio 2010\Projects\One Stop Management\One Stop Management\MainWindow.xaml:line 1 at One_Stop_Management.MainWindow..ctor() in C:\Users\Jason\Documents\Visual Studio 2010\Projects\One Stop Management\One Stop Management\MainWindow.xaml.cs:line 25 InnerException: System.IO.IOException Message=Cannot locate resource 'images/favicon.ico'. Source=PresentationFramework StackTrace: at MS.Internal.AppModel.ResourcePart.GetStreamCore(FileMode mode, FileAccess access) at System.IO.Packaging.PackagePart.GetStream(FileMode mode, FileAccess access) at System.IO.Packaging.PackWebResponse.CachedResponse.GetResponseStream() at System.IO.Packaging.PackWebResponse.GetResponseStream() at System.IO.Packaging.PackWebResponse.get_ContentType() at System.Windows.Media.Imaging.BitmapDecoder.SetupDecoderFromUriOrStream(Uri uri, Stream stream, BitmapCacheOption cacheOption, Guid& clsId, Boolean& isOriginalWritable, Stream& uriStream, UnmanagedMemoryStream& unmanagedMemoryStream, SafeFileHandle& safeFilehandle) at System.Windows.Media.Imaging.BitmapDecoder.CreateFromUriOrStream(Uri baseUri, Uri uri, Stream stream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption, RequestCachePolicy uriCachePolicy, Boolean insertInDecoderCache) at System.Windows.Media.Imaging.BitmapFrame.CreateFromUriOrStream(Uri baseUri, Uri uri, Stream stream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption, RequestCachePolicy uriCachePolicy) at System.Windows.Media.ImageSourceConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value) at System.Windows.Baml2006.TypeConverterMarkupExtension.ProvideValue(IServiceProvider serviceProvider) at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CallProvideValue(MarkupExtension me, IServiceProvider serviceProvider) InnerException: "
Why is this thing giving me attitude? I'm just trying to insert an image...
Here is the XAML that was produced for the icon when I tried to add the Icon using the Properties Pane:
<Fluent:RibbonWindow x:Class="One_Stop_Management.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Fluent="clr-namespace:Fluent;assembly=Fluent"
Title="One Stop Management" Height="727" Width="1208" Icon="Resources\favicon.ico">
I can't even add an icon using the properties pane, below is the error it gives me.
To add an icon to a project, right click on the project name in Solution Explorer. Right click will open Add Items menu. Select Add >> New Item. Now on Installed Templates, select Icon File (see Figure 1) and click Add.
Setting BuildAction
to Resource
in resource Properties
solved this problem.
Greets
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With