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

前端 未结 2 521
臣服心动
臣服心动 2020-12-17 10:15
  • 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 be
相关标签:
2条回答
  • 2020-12-17 10:48

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

    0 讨论(0)
  • 2020-12-17 10:48

    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

    0 讨论(0)
提交回复
热议问题