Search code examples
wpfxamlresourceswindowpack

What is application's site of origin and when to use it


  • What is application's site of origin
  • When to use it
  • How is the build action of a resource file associated with it
  • What is the difference between pack://application:,,, and pack://siteoforigin:,,,

Solution

  • The site of origin is the location (i.e. the physical folder) of the application executable assembly (i.e. the .exe that the user runs). The URI is thus relative to that folder.

    Example: You have

    • C:\Programs\MyApp\MyApp.exe
    • C:\Programs\MyApp\MyIcon.bmp
    • C:\Programs\MyApp\Icons\MyOtherIcon.bmp

    The pack URIs are pack://siteoforigin:,,,/MyIcon.bmp and pack://siteoforigin:,,,/Icons/MyOtherIcon.bmp when running the MyApp.exe. That means you have to copy those files to those places.

    In contrast, the application pack URI refers to resources embedded in your assembly (by using Build Action "Resource").