如何使用资源构建独立的exe? [英] How to build a stand alone exe with resources?
本文介绍了如何使用资源构建独立的exe?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有图像资源的WPF应用程序.生成程序时,包含我的图像的bin文件夹中有一个名为"resources"的目录.如果我在没有文件夹的情况下运行该程序,它将崩溃.如何在应用程序中嵌入资源,使其可以独立运行?
I have a WPF app with image resources. When I build the program, there is a directory named "resources" in the bin folder containing my images. If I run the program without the folder, it crashes. How can I embed the resources in the app so it can run stand alone?
推荐答案
您必须将图像文件的构建操作设置为 Resource
,如所示
You have to set the build action of the image files to Resource
, like shows here. The Uri for an image file named Image.png
would then be this:
pack://application:,,,/Resources/Image.png
另请参见MSDN页面在WPF中打包URI .
See also the MSDN page Pack URIs in WPF.
这篇关于如何使用资源构建独立的exe?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文