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.

Image

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 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.