Resources

Hi,

I'm using a few bitmaps in my app and have added them using the "Add Existing Item" to the solution. I've set their "Build Action" to "Embedded Resource". Once I build the solution and look at the app dll in ILDSM it shows the resources in the manifest... 

.mresource public Application.Image1.bmp
{
}

.mresource public Application.Image2.bmp
{
}

etc...

But for some reason I am not able to access these images using ResourceManager.

I create the ResourcesManager object...

ResourceManager resources = new ResourceManager( "Application.UI", Assembly.GetExecutingAssembly() );

"Application" is the default namespace and there is a file called UI.resx which actually contains the resources.

I have actually used a GUI app called Resourcer (http://www.aisto.com/roeder/dotnet/) to view the images in UI.resx. It seems that those images don't appear in UI.resx. So I added them using this app. Then when I build and run my app, I am able to access the images. 

Problem is that once I close Visual Studio .NET, reopen it, build the app and run it again it doesn't work. The images are gone from UI.resx. 

Don't really know what's going on. Help!

Thanks


Answer this question

Resources

  • sashka76

    I would like the image to be in a resource. Essentially it would be ideal if all the images were in a resource assembly. This way I can just distribute that one assembly and have all the images included rather than have them separate.

    See, the wierd thing is that it works - I am able to use the images in the app - but once I start up VS .NET again and rebuild the solution, they seem to disappear from the assembly. Maybe it's some setting I need to change.

  • Bill Simpson

    you access them by the name of the file and any folders it's located in...

    if the image is in the root of your project, use just "Image1.bmp".  If it's located in an "images" folder, you'd use "images.Image1.bmp" to access it, etc...not sure if that'll help

  • Rod Landers

    when you go to the properties of the images in your project and change the build action to embed resource, it will embed them into the assembly (the dll itself) when you compile.  They will still be there when you come back into VS.NET...the resx files have nothing to do with it, other than storing stuff to be used at design time...at runtime, everything should be coming from the assembly itself as it won't have anything to do with the resx files
  • Resources