我正在WPF應用程序和.exe被發現超過1.2MB的大小。我想減小最終可執行文件的大小。該代碼不超過幾個200 Kb,我在項目中使用了幾個.png圖像,這些圖像共佔用大約20kb。爲什麼最終的可執行文件如此之大?我使用ILDASM統計信息來查看.exe統計信息。發佈以下輸出:WPF .exe - 大文件大小
File size : 1267712
PE header size : 512 (496 used) (0.04%)
PE additional info : 1547 (0.12%)
Num.of PE sections : 3
CLR header size : 72 (0.01%)
CLR meta-data size : 72524 (5.72%)
CLR additional info : 1160002 (91.50%)
CLR method headers : 3189 (0.25%)
Managed code : 28702 (2.26%)
Data : 2048 (0.16%)
Unaccounted : -884 (-0.07%)
Num.of PE sections : 3
.text - 1265152
.rsrc - 1536
.reloc - 512
CLR meta-data size : 72524
Module - 1 (10 bytes)
TypeDef - 58 (812 bytes) 0 interfaces, 0 explicit layout
TypeRef - 250 (1500 bytes)
MethodDef - 647 (9058 bytes) 0 abstract, 0 native, 639 bodies
FieldDef - 216 (1296 bytes) 10 constant
MemberRef - 481 (2886 bytes)
ParamDef - 460 (2760 bytes)
MethodImpl - 11 (66 bytes)
Constant - 11 (66 bytes)
CustomAttribute- 506 (3036 bytes)
StandAloneSig - 73 (146 bytes)
InterfaceImpl - 27 (108 bytes)
PropertyMap - 29 (116 bytes)
Property - 233 (1398 bytes)
MethodSemantic- 304 (1824 bytes)
TypeSpec - 30 (60 bytes)
Assembly - 1 (22 bytes)
AssemblyRef - 13 (260 bytes)
ManifestResource- 2 (24 bytes)
NestedClass - 17 (68 bytes)
EventMap - 5 (20 bytes)
Event - 7 (42 bytes)
MethodSpec - 12 (48 bytes)
Strings - 21669 bytes
Blobs - 18740 bytes
UserStrings - 6244 bytes
Guids - 16 bytes
Uncategorized - 229 bytes
CLR additional info : 1160002
Resources - 1160002
CLR method headers : 3189
Num.of method bodies - 639
Num.of fat headers - 169
Num.of tiny headers - 470
Num.of fat sections - 3
Num.of small sections - 25
Managed code : 28702
Ave method size - 44
正如您所看到的,CLR附加信息佔用了大部分空間。我在我的項目中使用所有視覺樣式作爲StaticResource
,我認爲沒有太大的區別?如何解釋大的.exe大小? (建立在釋放模式64項目)
UPDATE:
我的構建選項:
Configuration - Release
Platform - x64
Optimize code - enabled
Allow unsafe code - disabled
Conditional comppilation symbols - none
我對試圖理解什麼是CLR附加信息的貢獻有興趣...... :)我可以使用1.2 MB的exe文件;) – jester
請顯示您的編譯器/編譯選項。 Btw空格也是'代碼',所以代碼量不是輸出大小的最佳指示。但是這裏肯定有一些東西,我有更大的代碼庫產生更小的程序集。 – stijn
@stijn用生成選項更新了這個問題 – jester