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

2

22
  • 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:,,,
Bicephalous answered 18/5, 2011 at 10:21 Comment(0)
W
29

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

Wingless answered 18/5, 2011 at 10:29 Comment(1)
I would further refer to the Pack Uri page on MSDN.Saadi
A
6

If you do not want to be bound by the restrictions of having your application resources declared at compile time, there is another option for you. No, this doesn't involve using fully qualified Uris to reference resources over the internet. Although, that is indeed supported. WPF provides you with an abstraction for the application's conceptual site of origin i.e. the location from where the application was deployed. For instance, if your application was launched from http://nerddawg.blogspot.com , then your application's site of origin is http://nerddawg.blogspot.com . To access an image at images/AuntDahlia.gif at that location, you would specify in markup:

<Image Source="pack://siteoforigin:,,,/images/AuntDahlia.jpg" />

for more

http://nerddawg.blogspot.com/2005/11/resources-in-windows-presentation.html

Adolescence answered 18/5, 2011 at 10:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.