How to: Reference a file embedded within a DLL in WPF
Componentqualifier in your relative URI.
Suppose you have a reference assembly (declared as
Referencein your project), which contains an image file that you'd like to access. In markup, you can write:
<Image Source="/MyReferenceAssembly;Component/MyImage.jpg" />
Componentqualifies MyReferenceAssembly as being a reference assembly. The reference assembly must always be the first segment in such a relative URI. The example above is a common short form of the actual usage. The full form involves the assembly's strong name in order to unambiguously address a specific assembly at runtime. You can extend this concept to assemblies in the Global Assembly Cache (GAC) as well.
The actual long form of this URI syntax involves referencing the assembly in a URI segment with the following syntax:
- Each parameter within this URI segment is delimited by a semi-colon (
ComponentDisplayNameis the display name of the assembly or library, and is mandatory
- The optional
VersionNumberis a dotted-decimal string prefixed with a
- The optional
PublicKeyTokenis the hexadecimal form of the public key token. In string form, it is represented in 16 characters
- The keyword
Componentis mandatory when referencing assemblies or libraries
- A true strongly named component requires all of the above to be specified.
None of the above parameters are required to be case-sensitive. Each of the following represents a legal use of this syntax:
<Image Source="/MyLibrary;v18.104.22.168;9b35aa32c18d4fb1;Component/MyImage.jpg" />
<Image Source="/MyLibrary;Component/MyImage.jpg" />
<Image Source="/MyLibrary;v22.214.171.124;Component/MyImage.jpg" />
<Image Source="/MyLibrary;9b35aa32c18d4fb1;Component/MyImage.jpg" />
<Image Source="/MyLibrary;9B35AA32C18D4FB1;component/MyImage.jpg" />