1.5. Embed a Resource File in an Assembly

Problem

You need to create a string-based resource file and embed it in an assembly.

Solution

Use the Resource Generator (resgen.exe) to create a compiled resource file. You then use the /resource switch of the compiler to embed the file in the assembly.

NOTE

The Assembly Linker tool (al.exe) also provides functionality for working with and embedding resource files. Refer to the Assembly Linker information in the .NET Framework SDK documentation for details.

How It Works

If you need to store strings in an external file and have them accessible to your assembly, you can use a resource file. Resources are some form of data (a string or an image, for example) that is used by an application. A resource ...

Get Visual Basic 2008 Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.