Welcome to MSDN Blogs Sign in | Join | Help

Forms-Based Resources vs. Project Resources

A recent bug (okay, it's WAY old and I only just got to it - my bad) makes it clear that we don't differentiate clearly enough in our documentation between forms-based resources and project resources. So here's the skinny. (I've added some of this information to our walkthrough for the next doc update.)

Forms-based resources are created when you set the Localizable design-time attribute on a Form to true, and then set specific resources for various settings of the Language attribute. On Image properties, such as BackgroundImage on Form or Image on PictureBox, when you use the snazzy new Import... button, you are importing a forms-based resource. (The UI calls it a "local resource".) Forms-based resources are weakly typed behind the scenes. Usually this is fine, as Visual Studio takes care of all the messy details for you of generating satellite assemblies and switching resources based on the current UI culture.

Project resources are created manually, by adding a new project resources file for a specific language. The plus side is that project resources are strongly typed, and thus easier to manipulate programmatically.

What resource type should you use when? In general, use forms-based resources for anything that's form-specific; use project resources for error strings, or anything else that is application-global or that you need to assign programmatically.

Here's an important tip, though: NEVER mix resource types for the same property! The bug I received was created because a customer tried to set the default Image on a PictureBox using a project resource, then set language variants using the Import... button (which uses forms-based resources). The result? We ignore the project resources entirely, so the default image never showed up.

Let me know if this isn't clear, or if you feel the walkthrough could use even more detail. There's still time to get more text in before the next doc update!

Published Tuesday, January 31, 2006 7:26 PM by WinFormsUE

Comments

No Comments
Anonymous comments are disabled
 
Page view tracker