Home Overview Localization of .NET assemblies - .NET Resources
Localization of .NET assemblies - .NET Resources PDF Print E-mail
Article Index
Localization of .NET assemblies
.NET Resources
#US Stream Strings
.NET WinForm Designer
.NET Resource Editor
All Pages

.NET resources

A standard .NET resource may have different formats, such as binary (- .resources), XML (- .resx), text and others. Regardless of the format, a resource contains a list of properties (fields, IDs, etc) and their values. The user can specify the type of value for properties. The type of string values is not specified. See an example of a resource file in XML (fragment):

<data name="Label1.Size" type="System.Drawing.Size, System.Drawing">

<value>109, 13</value>

</data>

<data name="Label1.TabIndex" type="System.Int32, mscorlib">

<value>15</value>

</data>

<data name="Label1.Text" xml:space="preserve">

<value>UI Current Culture</value>

</data>

A .NET application stores and processes all string data in UNICODE (UTF-8 in resources, USC-2 in code). Files of .NET resources built in a PE file have the binary format.

Resources of visual objects and code to load them are generated by the development environment automatically as the user designs a form, or a user control in the form designer. Some properties are not saved to a resource if their values match the default values. However, special properties can be saved to a resource, which are, as a rule, used only by the design environment and ignored by the code of a PE file. Usually, the prefix >> is added to the name of such properties (>> in XML):

<data name=">>ColumnHeader6.Name" xml:space="preserve">

<value>ColumnHeader6</value>

</data>

<data name=">>ColumnHeader6.Type" xml:space="preserve">

<value>System.Windows.Forms.ColumnHeader, System.Windows.Forms,

Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>

</data>

<data name=">>$this.Name" xml:space="preserve">

<value>MainForm</value>

</data>

<data name=">>$this.Type" xml:space="preserve">

<value>System.Windows.Forms.Form, System.Windows.Forms,

Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>

</data>

By default, special properties are labeled as Read-only.

The development environment generates the data of a resource and code for its loading dynamically depending on the state of properties. The code for loading a resource of a visual object is created in the InitializeComponent method in the source file of an application as text. Then, source files are compiled to create PE files. The InitializeComponent method is called from the object constructor. The code loads necessary resources on application launch depending on the culture settings of the calling thread (Thread.CurrentThread.CurrentUICulture).

If a visual object does not require localization and it is specified in the design environment, the design environment creates a resource with a minimal set of data or does not create it at all. This also means that the code for loading resources is not created either.

Of course, the developer can embed his own code into an application but it is not typical.

As resources are extracted from a .NET assembly, Radialix 2 analyses classes – ancestors of visual components, interprets the code of the InitializeComponent method and adds missing resources to a project and inserts missing hard-coded elements (H status) to resources themselves. This is necessary to edit properties and update resources correctly. When localized assembles are created, the code for loading resources can be embedded to the created file. This function is not supported for creation of resource assemblies.