应用程序的来源站点是什么以及何时使用它

发布于 2024-11-07 19:35:38 字数 169 浏览 1 评论 0 原文

  • 什么是应用程序的源站点
  • 何时使用
  • 它 与其关联的资源文件的构建操作如何 如何
  • pack://application:,,, 和 pack://siteoforigin:,,,< 之间有什么区别/强>
  • 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:,,,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

影子的影子 2024-11-14 19:35:38

源站点是应用程序可执行程序集(即用户运行的.exe)的位置(即物理文件夹)。因此,URI 是相对于该文件夹的。

示例:您有

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

包 URI 为 pack://siteoforigin:, ,,/MyIcon.bmppack://siteoforigin:,,,/Icons/MyOtherIcon.bmp 运行 MyApp.exe 时。这意味着您必须将这些文件复制到这些位置。

相反,应用程序包 URI 引用程序集中嵌入的资源(通过使用生成操作“资源”)。

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

疯了 2024-11-14 19:35:38

如果您不想受到在编译时声明应用程序资源的限制,那么还有另一种选择。不,这不涉及使用完全限定的 Uris 来引用互联网上的资源。虽然,这确实是支持的。 WPF 为您提供了应用程序概念源站点的抽象,即部署应用程序的位置。例如,如果您的应用程序是从 http://nerddawg.blogspot.com 启动的,那么您的应用程序的原始站点是 http://nerddawg.blogspot.com 。要访问该位置的 images/AuntDahlia.gif 图像,您可以在标记中指定:

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

了解更多

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文