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

Tom Hintz 21 Reputation points
2020-09-29T12:23:00.057+00:00

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,182 questions
No comments
{count} votes

Accepted answer
  1. Zhanglong Wu-MSFT 251 Reputation points Microsoft Employee
    2020-09-30T02:33:38.577+00:00

    Hi TomHintz,

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

    29189-2020093001.png

    Best regards,
    Zhanglong


1 additional answer

Sort by: Most helpful
  1. Tom Hintz 21 Reputation points
    2020-09-30T12:26:21.17+00:00

    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.

    No comments