WPF: Cannot locate resource 'resource/favicon.ico' on main Window Icon (simple question)

Tom Hintz 21 Reputation points

I created my fist WPF app under .Net Core 3.1 in the latest VS 2019. Its just the stock Window when the project is first created and I want to set the Windows icon so I visited the project properties and clicked the link to add Resources. This creates Resources.resx under a Properties folder. I imported an existing favicon.ico into the resources and then tried setting the main Window's Icon="Resources/favicon.ico" resulting in an error for that property.

I've read that a "build action" is needed but I see no button or property for that.

How is the problem resolved? Thanks,

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,626 questions
0 comments No comments
{count} votes

Accepted answer
  1. Zhanglong Wu-MSFT 261 Reputation points Microsoft Vendor

    Hi TomHintz,

    In Solution Explorer set the image file's Build Action property to Resource. Then clean the solution and rebuild it.


    Best regards,

    5 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Tom Hintz 21 Reputation points

    Thank you for the answer. Actually, I had imported an existing item into the resource, but that does not copy the resource into the resource folder. I manually copied the resource and then your solution works.

    0 comments No comments