WPF .exe - large filesize

后端 未结 2 1641
栀梦
栀梦 2021-02-14 12:31

I am working on a WPF application and the .exe is found to be over 1.2MB in size. I would like to reduce the size of the final executable. The code is no more than a few 200 Kb,

相关标签:
2条回答
  • 2021-02-14 12:58

    This is probably an issue with embedded resources.

    If you added images or other resources to the project, even if you delete the file from the project, the resource will remain embedded.

    Check the Resources section of project properties.

    For example, did you add your images as bitmaps first and later deleted the files and added as png?

    0 讨论(0)
  • 2021-02-14 13:06

    Indirectly referenced default styles with all dependencies they have are usually not visible in code or XAML. I am not sure but if WPF is embedding them into the exe, this could account for some of the overhead. You could test this by removing most of the WPF-dependent code to see whether this significantly influences file size.

    There could also be an overhead due to being WPF and being executable. You could test this by putting your code into a WPF Custom or User Control Library Project. This can be created by visual studio. If for the same content the resulting DLLs are much smaller than the EXE-files, it might be a combination of WPF and being an executable.

    In general, I find a file size overhead not surprising. As a big framework WPF is not known for its tininess and efficiency.

    The two comments to the answer here: "Why is my .net exe so huge" analyzer tool? might also be helpful.

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