tags:

views:

1035

answers:

3

What happens to the name/value pairs stored inside a form's resx file? Are they compiled into the binary when I compile my project?

For my particular project, I would like the ability to edit one of these values manually without recompiling (app.config-style), is there a simple way to do this?

EDIT: Some people seem to not be getting my question. When doing WinForms, if the set-up inside of InitializeComponents() depends on the form's resource file, simply setting the build action to copy always and the content type to content breaks the form. I am sure that there is a simple solution, but not having worked with resource files before am confused as to what it would be.

+2  A: 

Sure open it in any text editor, it's just xml. You can tell VS not to embed them in the properties.

nportelli
The second sentence is what I can't figure out how to do
George Mauer
I think that part may be wrong.
nportelli
http://www.c-sharpcorner.com/Articles/Default.aspx?ArticleId=1fa89582-584b-4640-a95c-d705302fe064 is fairly informative.
nportelli
+4  A: 

If you put the values in the .resx file, by default they get compiled into your assembly (or a satellite resource assembly).

If you want the ability to edit the values at runtime, you should really use either app.config or the registry. I personally prefer the app.config file.

The easiest way to put the value in the app.config file would be to use the Settings tab in the project Properties.

If you insist on keeping your values in an .resx file, I guess you could treat that particular .resx file as a an XML content file and just copy it to the output directory. I am not sure what framework classes are there to help you with parsing this file and consuming its content, though. You might have to resort to XmlDocument and your own XL parsing to extract/modify the values.

Franci Penov
I agree about using the app.config file in most cases, don't have a choice here though, its a third party control
George Mauer
I doubt any third-party control will consume raw .resx files. I suspect they would expect a resource assembly instead. I might be wrong about that, though.
Franci Penov
This is definately going to be your best "quick" implementation without a lot of extra code.
Tom Anderson
A: 

Go to the properties for your .resx file in Visual Studio and set the Build Action to Content. That should set it to not compile and you'll be able to copy over the .resx file with the site and modify it anytime.

You may want to clean any compiled resources out of your project, I'm not sure if ASP.NET will look for those first since they have been compiled once.

EDIT: just saw you were referencing WinForms, not sure about that.

Cruiser