ResXToResources.exe is a resource file generator utility that reads .ResX (XML-based resource format) files and produces a NGWS runtime binary .resources file that can be embedded in a NGWS runtime binary executable.
ResXtoResources [/compile input.resX output.resources] [/decompile input.resources output.resX]
Argument | Description |
---|---|
/compile input.resX output.resources | Create a .resources file based on the contents of the .resX file |
/decompile input.resources output.resX | Create a .resX based on the contents of the .resource file |
If you are creating a Win Forms C# application MyCompany.App1 that uses a bitmap as the background for a Button, you would start by creating a App1.resX file as follows:
<root> <schema id="root" targetNamespace="" xmlns="http://www.w3.org/1999/XMLSchema" xmlns:xdo="urn:schemas-microsoft-com:xml-xdo" xdo:DataSetName="root"> <element name="data"> <complexType content="textOnly"> <attribute name="name" minOccurs="1" type="string"></attribute> <attribute name="type" type="string"></attribute> <attribute name="mimetype" type="string"></attribute> <element name="value" minOccurs="0" type="string"></element> </complexType> </element> <element name="resheader"> <complexType content="textOnly"> <attribute name="name" minOccurs="1" type="string"></attribute> <element name="value" minOccurs="0" type="string"></element> </complexType> </element> </schema> <root> <resheader name="ResMimeType"> <value>text/microsoft-resx</value> </resheader> <resheader name="Version"> <value>1.0.0.0</value> </resheader> <resheader name="Reader"> <value>System.Resources.ResXResourceReader</value> </resheader> <resheader name="Writer"> <value>System.Resources.ResXResourceWriter</value> </resheader> <data name="button1.BackgroundImage" mimetype="text/microsoft-urt/psuedoml-serialized/base64"> <value> THE ACTUAL BITMAP RENDERED AS A BASE64 STRING</value> </data> </root> </root>
You then create a .resources file as follows:
ResXToResource /compile App1.resX App1.resources
Since the utility is case sensitive, the /compile and /decompile flags should be written in lowercase. Also, the utility does not provide automatic filename extensions, so you should make sure to add them yourself.
Having created the .resources file you can refer to it in your application (assuming C#) as follows:
System.Resources.ResourceManager resources = new System.Resources.ResourceManager("App1", typeof(App1), null, true); button1.BackgroundImage = (System.Drawing.Image)resources.GetObject("button1.BackgroundImage");
You then build App1.exe including the .resources file as a resource:
csc /res:App1.resources, Win32Form1Namespace.App1.resources /out:App1.exe *.cs
The /res flag takes two parameters: the name of the physical file and the namespace in which that file will exist. Both parameters are case sensitive. In this example, App1.resource represents the resource file that will be compiled into the assembly, while Win32Form1Namespace.App1.resources informs the compiler that the resource file belongs to the form namespace.