4

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.

3 Answers 3

4

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.

3
  • I agree about using the app.config file in most cases, don't have a choice here though, its a third party control Oct 20, 2008 at 18:23
  • 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. Oct 20, 2008 at 18:48
  • This is definately going to be your best "quick" implementation without a lot of extra code. Oct 22, 2008 at 2:23
2

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

2
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.