Introduction
A .resx file holds the resources of a .NET program in XML: the strings of a form or an application, its pictures and icons, its sizes, colours and positions, and any other value that has a text form or can be serialised. It is the source form: the build turns it into a binary .resources file that is embedded in the assembly, and the program reads it through ResourceManager. Windows Forms designers wrote one for every form (Form1.resx beside Form1.cs), ASP.NET used them for localisation, and a project’s Properties/Resources.resx holds the strings and images the developer adds. .resw is the same shape of file used by UWP and WinUI for the strings of the user interface, where it is named with the culture in a folder and read by the x:Uid of XAML elements. XAML itself does not use .resx for its own text, but a XAML application refers to resources through x:Static and x:Uid.
The file is one <root> element. It starts with an inline XSD schema that describes the rest, then resheader entries that name the reader and writer classes, assembly aliases, and data and metadata entries. A data entry has a name, an optional type and mimetype, a value, and an optional comment.
<?xml version="1.0" encoding="utf-8"?>
<root>
<!-- xsd:schema … (the standard inline schema) -->
<resheader name="resmimetype"><value>text/microsoft-resx</value></resheader>
<resheader name="version"><value>2.0</value></resheader>
<resheader name="reader"><value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value></resheader>
<resheader name="writer"><value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value></resheader>
<data name="Greeting" xml:space="preserve">
<value>Hello, world</value>
<comment>Shown on the first page</comment>
</data>
<data name="button1.Location" type="System.Drawing.Point, System.Drawing">
<value>12, 20</value>
</data>
<data name="logo" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\logo.png;System.Drawing.Bitmap, System.Drawing</value>
</data>
</root>
The kinds of file
| Extension | What it is | Page |
|---|---|---|
.resx | a .NET resource file, as above; Name.fr.resx or Name.fr-CA.resx are the files of one culture | File structure and schema |
.resw | the UWP and WinUI resource file, with the same shape, whose names read Uid.Property | Localisation and the build |
.resources | the binary form the build makes from a .resx; not text and not read by this viewer | Localisation and the build |
How the viewer reads each file
A file is read as a resource file when its root element is <root> (no prefix) and the start of it holds a resheader, data, metadata or assembly element or the inline schema. Any other .resx or .resw file is shown as plain XML. A file over 24 MiB is read by the XML viewer, in windows. The tabs:
| Tab | What it shows |
|---|---|
| Overview | the format, the header values, the counts of entries by kind, the images found, and the XML overview underneath |
| Entries | every data and metadata entry in pages: line, kind, name, type, mimetype, the decoded value, the size of a binary value, and the comment; for a .resw file the name split into uid and property. An embedded picture, icon or SOAP text has an Open button that opens it as its own file |
| Headers | every resheader and assembly alias |
| Problems | every problem, in pages with line and column |
| Text | the file as coloured XML |
The decoding of a value follows the rules of ResXDataNode: no type is a string; a type with no mimetype is typed text read by its converter (checked here for the common types: Boolean, the integer and floating point types, Point, Size, Rectangle, Padding), System.Byte[] is base64, ResXFileRef is a file reference, ResXNullRef is null; the three mimetypes are decoded as base64, and a BinaryFormatter stream is read record by record (BinaryFormatter streams); nothing is deserialised or run. The problems are: a missing or wrong resheader (the reader refuses such a file), a name used twice, names that differ only by case, an entry with no name or no value, extra values or children, base64 that is not valid, a BinaryFormatter stream that is damaged, a mimetype the reader does not know, a malformed file reference, a typed value that its type cannot read, and an unknown element.
The pages
- File structure and schema – the root, the inline schema, headers, assemblies, data, metadata and comments
- Types, mimetypes and values – how each value is stored and read, base64, file references, images and icons
- BinaryFormatter streams – the record format inside the binary base64 values
- Localisation and the build – cultures, designer files,
.resources,.reswand MSBuild - Tooling – the .NET classes and tools that read and write resource files
Not described
Known, not yet covered
- Reference: the binary
.resourcesfile and the satellite assembly format are named, not described. - Viewer: the
ImageListStreamerof Windows Forms image lists (aDatamember that starts withMSFt) is shown with its size and the name of its class, not decoded into images. Fonts, colours and other typed text are shown as text: the viewer checks the common types only and does not know the names of colours or enumeration members. - Viewer: a file reference is shown, not followed: the file it names is not on the machine of the viewer.
- Viewer: the inline XSD schema is recognised, not checked against the file.
Unknown
- Reference: the .NET resource reader was not run here (no .NET SDK is installed); the rules come from the source of
ResXResourceReader,ResXDataNodeandResXFileRefin the Windows Forms repository.
Links
Software
- Visual Studio – the resource designer edits .resx files as a table of strings, images, icons and files (Windows)
- Windows Forms – the designer that writes a .resx for each form, and the source of the reader and writer (Windows)
Developers
- ResXResourceReader and ResXResourceWriter – the .NET classes that read and write the format (C#)
- ResXDataNode and ResXFileRef – one entry, and a reference to a file (C#)
- System.Resources.Extensions – the package that reads and writes the serialised values without BinaryFormatter (C#)
Reference
- Resources in .NET – Microsoft’s overview of .resx, .resources and the resource manager
- Creating resource files – the format’s elements as the documentation gives them
- XAML – the markup that refers to resources by key and by x:Uid (on this site)