Embedded Resources

Besides acting as containers for code and metadata, assemblies can also store resources for use at runtime. Visual Studio directly supports the creation of such assemblies by including files in the project and marking their build action as embedded resource. This is illustrated in Figure 25.35 for a file that was added to the project using the Add, Add Existing Item entry from the project’s context menu in Solution Explorer.


FIGURE 25.35 Marking a file to be included as an embedded resource in the assembly.

Now this stream can be accessed using the System.Reflection APIs on the Assembly type, using the GetManifestResourceStream ...

Get C# 5.0 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.