Page 21 - DCAP408_WEB_PROGRAMMING
P. 21
Unit 1: Windows Programming Basics
Resource Files: Data files that are compiled into either an executable or library WPF Notes
assembly.
Content Files: Standalone data files that have an explicit association with an executable
WPF assembly.
Site of Origin Files: Standalone data files that have no association with an executable WPF
assembly.
One important distinction to make between these three types of files is that resource files and
content files are known at build time; an assembly has explicit knowledge of them. For site of
origin files, however, an assembly may have no knowledge of them at all, or implicit knowledge
through a pack uniform resource identifier (URI) reference; the case of the latter, there is no
guarantee that the referenced site of origin file actually exists.
Resource Files
If an application data file must always be available to an application, the only way to guarantee
availability is to compile it into an application's main executable assembly or one of its referenced
assemblies. This type of application data file is known as a resource file.
You should use resource files when:
You don't need to update the resource file's content after it is compiled into an assembly.
You want to simplify application distribution complexity by reducing the number of file
dependencies.
Your application data file needs to be localizable (see WPF Globalization and Localization
Overview).
Configuring Resource Files
In WPF, a resource file is a file that is included in a Microsoft build engine (MSBuild) project as
a Resource item.
Notes In Microsoft Visual Studio, you create a resource file by adding a file to a project and
setting its Build Action to Resource.
When the project is built, MSBuild compiles the resource into the assembly.
LOVELY PROFESSIONAL UNIVERSITY 15