Search code examples
.net.net-assemblyembedded-resourcesharpdevelop

SharpDevelop- Cannot find embedded resource at design time


In my Windows Forms application, I add an image as a resource (Embedded) which I'm trying to use as a background image for a control.

When I click on the Properties of the control and the Select Resource pops up , the Project Resource tab/option is empty. Shouldn't it contain the image I've added as a resource?

When I use the Local Resource and choose it from the drive, it gets attached to the control ok but when I re-open the project another time, the image is missing hence the control has no background image property

The resource is added in the manifest as

<data name="background" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
    <value>
...
    <\value>

but does not show up in the Project Resource tab

what am I doing wrong ?


Solution

  • Adding an image to your project and settings its Build Action to EmbeddedResource will not make it available to add to your Windows Form via a Project Resource. The Windows Forms designer needs the image inside a resource file (.resx) in order to be able to access use it as a Project Resource. To do this you can add a new Empty resource file to your project.

    Empty resource file template

    Then you can add your image to the resource by opening the resource file into the editor, right clicking, selecting Add Files, and finally selecting the image. In the screenshot below I have added an image already.

    Image in Resources.resx file

    Then your image should be available when changing a background for a control.

    Forms designer - selecting image in project resource

    Now I am unable to reproduce the problem where an image added as a Local Resource going missing. I am using SharpDevelop 4.4.1 and have created a Windows Forms application targeting .NET 4.5. The image is always available even after closing and re-opening the project or SharpDevelop itself.