Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Resource file issues
Message
General information
Forum:
ASP.NET
Category:
Forms
Miscellaneous
Thread ID:
01321945
Message ID:
01321952
Views:
13
Sorry, I see you need it for WinForms, but here is the code for Web Forms (from the sample by Scott Michell in case you need it):
protected virtual string ArrowDownImageUrlInternal
        {
            get
            {
                if (string.IsNullOrEmpty(ArrowDownImageUrl))
                    return Page.ClientScript.GetWebResourceUrl(this.GetType(), "FriendshipCircle.FCAdmin.skmControls2.ArrowDown.gif");
                else
                    return ArrowDownImageUrl;
            }
        }
        #endregion
>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.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform