Creating portable (non-installing) windows applications in C#

匆匆过客 提交于 2019-12-04 05:46:52

You can use ILMerge to merge all the assemblies into your executable. I'd expect your icon to already be an embedded resource - or you should at least be able to create it as such.

Targeting .NET 2.0 would make the application more widely portable in that it would just work on machines which only have .NET 2.0 installed - but I don't know what the proportions look like for 2.0 vs 3.5 deployment, and more importantly they may well not be the same as the proportions for deployment out of your target audience.

You can add any data (assemblies, icons, etc) required by your application as resources or embedded files.

Either use the resource editor, or if you want to get your hands dirtier, you can add any file by just right clicking on the project in the solution explorer and doing an "add existing item", getting properties on the file and setting Build Aciton to "Embedded Resource".

Resources like Icons can just be used directly - as in DrawIcon(Properties.Resources.MyIcon)

Data files can be loaded using Application.GetManifestResource (and related methods) to get a stream to load from. For example, for an assembly, you can use Assembly.Load() directly from the manifest resource stream for your resource.

You could also use Xenocode to Virtualize Your Applications. Specifically Xenocode Postbuild for .NET.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!