tags:

views:

343

answers:

1

I'd like to create a resource file (in te process of preparing for deployment), filling it with certain settings (big xml structure) and some texts but I'm not sure how to go about doing that.

I did find some examples using ResxResourceWriter but when trying to open it cannot find the resource-key. here's what I have so far :

    private void simpleButton1_Click(object sender, EventArgs e)
    {
        using (System.IO.MemoryStream oStream = new System.IO.MemoryStream())
        {
            this.layoutControl1.SaveLayoutToStream(oStream);
            using (ResXResourceWriter oWriter = new ResXResourceWriter(@"..\..\Properties\LayoutControl.resources.Resx"))
            {
                oWriter.AddResource("one", oStream.GetBuffer());
                oWriter.Generate();
                oWriter.Close();
            }
        }

    }

    private void simpleButton2_Click(object sender, EventArgs e)
    {
        ResourceManager rm = new ResourceManager("WindowsFormsApplication1.LayoutControl", Assembly.GetExecutingAssembly());
        var one = rm.GetObject("one");
        Console.WriteLine("");
    }

I create the resource by clicking simpleButton1, I then stop the app, do an add-existing-item into my project, recompile and click simplebutton2, then I get a

MissingManifestResourceException (Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "WindowsFormsApplication1.LayoutControl.resources" was correctly embedded or linked into assembly "WindowsFormsApplication1" at compile time, or that all the satellite assemblies required are loadable and fully signed.)

Can someone give me some pointers or better yet, a working example ? And I would prefer it if the resource would compile into a 'seperate' assembly like 'normal' resource files.

thanks, Jurjen.

+1  A: 

You're pretty close - the baseName you're passing in to the ResourceManager is a bit off.

Any resx files you compile in get named with the default namespace plus any folders in the path. In your post, you should be passing in "WindowsFormsApplication1.Properties.LayoutControl.resources".

djeebus
thanks djeebus, that worked great !!
Jurjen