Accessing Resources at the Site of Origin

Binary Resources
(Logical) Resources
These are arbitrary .NET objects stored (and named) in an element’s Resources property. It’s a fundamental piece of enabling software to be localized into different languages. It also enables higher productivity for developing software because the logical resources support enables you to consolidate information that might otherwise be duplicated, and even factor XAML files into more manageable chunks.
Although full-trust applications can hard-code a uniform resource locator (URL) or path for loose binary resources, taking advantage of the site of origin notion is a more maintainable approach. (In addition, it is required for partial-trust applications.)

The site of origin gets resolved to different places at runtime, depending how the application is deployed:
  • For a full-trust application installed with Windows Installer, the site of origin is the application’s root folder.
  • For a full-trust ClickOnce application, the site of origin is the URL or UNC path from which the application was deployed.
  • For a partial-trust XAML Browser Application (XBAP) or ClickOnce application, the site of origin is the URL or UNC path that hosts the application.
  • For loose XAML pages viewed in a web browser, there is no site of origin. Attempting to use it throws an exception.
pack://siteOfOrigin:,,,/logo.jpg : Loose at the site of origin 
pack://siteOfOrigin:,,,/A/B/logo.jpg : Loose at the site of origin in an A\B subfolder

댓글

이 블로그의 인기 게시물

Stop console process using Ctrl+C.