Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Resource file issues
Message
General information
Forum:
ASP.NET
Category:
Forms
Title:
Resource file issues
Miscellaneous
Thread ID:
01321945
Message ID:
01321945
Views:
54
I'm playing around with (what I thought) would be something pretty simple. I wanted to add some PNG images to my RESX file (Named ManagementResource.resx) to be used on a WinForm. I opened the RESX file, changed to Images, selected Add Resource > Add Existing File and selected my PNG files. The resx file is set-up as an Embedded Resource and the Custom Tool is set to ResXFileCodeGenerator. From what I understand VS should automatically create the ManagementResource.resource file and embed it in the assembly for me.

Now I want to get a reference to them and tried this:
ResourceManager resource = new ResourceManager("ManagementResource", Assembly.GetExecutingAssembly());

// Exception thrown on Image line
Image img = (Image)resource.GetObject("MyPNG");
The Image line throws an exception, "MissingManifestResourceException" - Count not found any resources appropriate for the specified culture or neutral culture.

I thought it might have used the original filename, so I've also tried:
Image img = (Image)resource.GetObject("MyPNG.png");
That gives me the same error.

I've found code which suggested just embedding the PNG directly as an Embedded Resource, then using Assembly.GetManifestResourceStream, which does work (and it's how I've currently set things up), but it seems like what I was doing should work.
-Paul

RCS Solutions, Inc.
Blog
Twitter
Next
Reply
Map
View

Click here to load this message in the networking platform