Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8592749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:49:27+00:00 2026-06-11T23:49:27+00:00

I’m trying to use a local resource to put an icon inside a Button.

  • 0

I’m trying to use a local resource to put an icon inside a Button. (C# Visual Studio 2012)

Directly inside my project i have a folder called “Resources” which contains “Icons/MyIcon.png”

The following code works (but is not using a relative path)

<Button Width="20" Height="20">
  <Button.Background>
        <ImageBrush ImageSource="C:\Documents\MyProject\Resources\Icons\MyIcon.png">
          </ImageBrush>
      </Button.Background>

However, i want it to use a relative path… so i tried the following

  <ImageBrush ImageSource="..\MyProject\Resources\Icons\MyIcon.png">

It compiles, but then gives me the error:

{"Cannot locate resource 'myproject/resources/icons/myicon.png'."}

Then i found an article that talked about referencing the project and said to do:

"/[ assembly name ];component[ path within the project ]"

so i tried that:

<ImageBrush ImageSource="/MyProject;component\Resources\Icons\MyIcon.png">

But it doesn’t work.

It DOES show up in the GUI-Builder… but when i actually try to “debug” the code… it fails to run.

If i change the path at all by adding ‘123’ for example:

 <ImageBrush ImageSource="/MyProject;component\Resources\Icons\MyIcon123.png">

i get a pre-compile error: “cannot find the file specified”.
Once i remove the ‘123’ the error goes away. And the icon again is displayed in the Form.
But when i run… i still get:

{"Cannot locate resource 'resources/icons/myicon.png'."}

What is going on? Why can it only find the resource BEFORE it runs? and not when i actually start?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T23:49:29+00:00Added an answer on June 11, 2026 at 11:49 pm

    Do you need to set the BuildAction of the image to Resource? Is it being built into the assembly? Or are you treating it like Content? In that case, you’d want to set the BuildAction to Content and set CopyToOutputDirectory appropriately.

    Here’s a link to an MSDN article treating Resources, Content files, etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to loop through a bunch of documents I have to put
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.