The Basics of Resource Files in .Net 1.1

I have posted my research project, which turned out to be a semester long assignment instead of a month as I had hoped ;)

Grant Killian also has a great entry on why to use resource files that you should check out.

The project (code named Henley): The Basics of Resource Files in .Net 1.1

Introduction
The purpose of this article is to give the reader a better understanding of some common ways to use resource files in .Net applications.  The goal of this article is to answer the following questions:
·         What are resources?
·         What are resource files?
·         How do you create resource files?
·         How do you use resource files?
·         How do you write code that uses resource files?

In order to answer these questions and give the reader a better understanding of resources in .Net version 1.1 we will walk through a small exercise with VS.Net and really looking to see what goes on behind the scenes as well as introduce several utility applications that will help you work with resources.  Then we will go through the code of a sample application that uses images and strings from resource files in order to see some real code that uses resource files.

In this article, I am not going to cover any ASP.Net or satellite assembly specific topics, I think they would be better explained in another article.

Read the complete article
Download Word version of complete article

Download the code (warning the sample application has images embedded in it so the file sizes are 8mg+ so only download what you want)
Sample Application - VB.Net version
Sample Application - C# version
Sample Application - C++ version
Utility - RFC and WinResourceFileCreator
Utility - RW and WinResourceWrapper

Utilities for working with resources
ResourceFileCreator
This is a utility that provides similar functionality as the .Net SDK ResGen.exe utility.
http://jasonhaley.com/articles/resourcefiles/resource%20file%20creator.htm

ResourceFileWrapper
This is a utility that can be used to generate a C# or Visual Basic.Net class that wraps your resource file.
http://jasonhaley.com/articles/resourcefiles/resource%20wrapper.htm

.Net SDK Tools
C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin

AL.exe
Assembly Linker - http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/html/cpgrfAssemblyGenerationUtilityAlexe.asp

CSC.exe
C# compiler - http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cscomp/html/vcrefcsharpcompileroptionslistedalphabetically.asp

ILDasm.exe
IL Dissembler – http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/html/cpconMSILDisassemblerIldasmexe.asp

ILAsam.exe
IL Assembler - http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/html/cpconMSILAssemblerIlasmexe.asp

ResGen.exe
Resource File Generator - http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/html/cpgrfResourceFileGeneratorUtilityResgenexe.asp

VBC.exe
Visual Basic Compiler - http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/valrfVBCompilerOptionsListedAlphabetically.asp

.Net SDK Tutorials and code
C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Samples\Tutorials\resourcesandlocalization

ResXGen
Console application sample utility that will generate an .resx file and add images to it (give the path to the image).

ResDump
Console application sample that will iterate all the resources in resource files

ResEditor
Windows form sample that will allow you to edit a resource file

Resource Editor for .resx files
http://www.microsoft.com/downloads/details.aspx?FamilyId=3FF9C915-30E5-430E-95B3-621DCCD25150&displaylang=en

ResView
http://www.gotdotnet.com/team/clr/bcl/demos/demos/zipfiles/ResViewCS.zip

Resourcer for .Net
http://www.aisto.com/roeder/dotnet/

Reflector
http://www.aisto.com/roeder/dotnet/

Resource Editor 1.2 for VS.Net
http://weblogs.asp.net/gmilano/archive/2004/11/12/256582.aspx

Assembly Viewer
http://www.codeproject.com/dotnet/asmex.asp

VS.Net Command Prompt Here
http://www.larkware.com/Articles/VS.NETCommandPromptHere.html

posted on Sunday, November 28, 2004 10:04 AM

Feedback

# re: The Basics of Resource Files in .Net 1.1

none of your links are working...:(
2/8/2005 2:10 AM | Luis Gonzalez

# re: The Basics of Resource Files in .Net 1.1

The code which is given for download is really good thanks
3/29/2005 9:32 PM | Madhusudhana K

# I have a question for you...

Hi

Within VS.net, I have added a folder (called RESOURCES) to my project (in the project explorer), which contains embedded resources, more specifically abc.htm and pic.gif

I know how to reference these objects from within the .net EXE (using System.Reflection), but it is referring to pic.gif from within abc.htm that I am having trouble with.

To get at pic.gif from within .net, I would use the reference:

ProjectName.RESOURCES.pic.gif

I know that the res: // protocol (within IE) can be used to reference resources within EXEs and DLLs in the form:

<img src="res://MyEXE.exe/XXX/pic.gif">

Where XXX is a numeric reference. By this rule of thumb, the following code should work:

<img src="res://MyEXE.exe/RESOURCES/pic.gif">

Except that it doesn't! I understand that the res: // protocol may not support .net assemblies, but this is what I am looking to confirm really. Can I get at pic.gif from the HTML file without using a resource hacker to manually embed numeric resource folders (and the actual pictures) each time? Is there an easy way to do this?

Any ideas?

Thanks
Gee
4/13/2005 3:36 AM | Gee

# re: The Basics of Resource Files in .Net 1.1

Yes, it is very good. But don't you know where i can download the tool al.exe ? I don't have it in the sdk tool (in v1.1\Bin) and the only link I have found on msdn website is over ("Page cannot be found").

Thank you.
4/27/2005 6:11 AM | Minh

# re: The Basics of Resource Files in .Net 1.1

hy.

i can't find resxgen.exe anywhere on my desktop. neither the folder *ResourcesAndLocalization* (where this tool should be). do you know where to find it? or can you compress it and mail me? (pocivald@hotmail.com)

thx.
ciao
7/25/2006 11:43 PM | dp

# re: The Basics of Resource Files in .Net 1.1

trying out
8/17/2006 3:48 AM | trying out

# re: The Basics of Resource Files in .Net 1.1

i could not get the file resgen.exe for download
9/11/2006 3:06 AM | rambau

# The Basics of Resource Files in .Net 1.1

i could't get the al.dll for anywhere in my system can any body send me to ramahrud@yahoo.co.in
9/11/2006 3:55 AM | rambabu

Post Comment

Title  
Name  
Url
Comment   
Please enter the following code into the box below to stop spammers

  
Enter Code Here *