我在.net 4.0上的c#中开发了我的第一个winform应用程序。编译后的输出有.exe和.dll文件。我检查可执行文件在合并之前运行正常。我使用ILMerge合并了这两个文件。我是第一次使用ILmerge。所以我一定在某处犯了一些错误,但我无法解决这个问题。我有一个没有任何错误的可执行文件。但是在打开结果文件时,它会崩溃。
Windows在应用程序崩溃时产生了这些错误详细信息:
Description:
Stopped working
Problem signature:
Problem Event Name: CLR20r3
Problem Signature 01: mywinapp.exe
Problem Signature 02: 1.0.0.0
Problem Signature 03: 52383768
Problem Signature 04: mscorlib
Problem Signature 05: 2.0.0.0
Problem Signature 06: 4ca2b851
Problem Signature 07: f99
Problem Signature 08: 14e
Problem Signature 09: System.TypeLoadException
OS Version: 6.1.7601.2.1.0.256.1
Locale ID: 16393
我安装了ILMerge,并在ILMerge位置的cmd中使用了以下命令来创建合并的.exe文件。
ilmerge D:\abc\RemittanceForm.exe D:\abc\PdfFileWriter.dll /out:D:\out\MyWinApp.exe /target:winexe /ndebug /log:D:\out\aaa.txt
日志文件内容如下:
ILMerge version 2.12.803.0 Copyright (C) Microsoft Corporation 2004-2006. All rights reserved. ILMerge D:\abc\RemittanceForm.exe D:\abc\PdfFileWriter.dll /out:D:\out\MyWinApp.exe /target:winexe /ndebug /log:D:\out\aaa.txt Set platform to 'v2', using directory 'C:\Windows\Microsoft.NET\Framework64\v2.0.50727\..\v2.0.50727' for mscorlib.dll Running on Microsoft (R) .NET Framework v2.0.50727 mscorlib.dll version = 2.0.0.0 The list of input assemblies is: D:\abc\RemittanceForm.exe D:\abc\PdfFileWriter.dll Trying to read assembly from the file 'D:\abc\RemittanceForm.exe'. Successfully read in assembly. There were no errors reported in Remittance Form's metadata. Trying to read assembly from the file 'D:\abc\PdfFileWriter.dll'. Successfully read in assembly. There were no errors reported in PdfFileWriter's metadata. Checking to see that all of the input assemblies have a compatible PeKind. Remittance Form.PeKind = ILonly PdfFileWriter.PeKind = ILonly All input assemblies have a compatible PeKind value. AssemblyResolver: Assembly 'Remittance Form' is referencing assembly 'System.Windows.Forms'. AssemblyResolver: Attempting referencing assembly's directory. AssemblyResolver: Did not find assembly in referencing assembly's directory. AssemblyResolver: Attempting input directory. AssemblyResolver: Did not find assembly in input directory. AssemblyResolver: Attempting user-supplied directories. AssemblyResolver: No user-supplied directories. AssemblyResolver: Attempting framework directory. Resolved assembly reference 'System.Windows.Forms' to 'C:\Windows\Microsoft.NET\Framework64\v2.0.50727\..\v2.0.50727\System.Windows.Forms.dll'. (Used framework directory.) AssemblyResolver: Assembly 'Remittance Form' is referencing assembly 'System'. AssemblyResolver: Attempting referencing assembly's directory. AssemblyResolver: Did not find assembly in referencing assembly's directory. AssemblyResolver: Attempting input directory. AssemblyResolver: Did not find assembly in input directory. AssemblyResolver: Attempting user-supplied directories. AssemblyResolver: No user-supplied directories. AssemblyResolver: Attempting framework directory. Resolved assembly reference 'System' to 'C:\Windows\Microsoft.NET\Framework64\v2.0.50727\..\v2.0.50727\System.dll'. (Used framework directory.) AssemblyResolver: Assembly 'Remittance Form' is referencing assembly 'System.Drawing'. AssemblyResolver: Attempting referencing assembly's directory. AssemblyResolver: Did not find assembly in referencing assembly's directory. AssemblyResolver: Attempting input directory. AssemblyResolver: Did not find assembly in input directory. AssemblyResolver: Attempting user-supplied directories. AssemblyResolver: No user-supplied directories. AssemblyResolver: Attempting framework directory. Resolved assembly reference 'System.Drawing' to 'C:\Windows\Microsoft.NET\Framework64\v2.0.50727\..\v2.0.50727\System.Drawing.dll'. (Used framework directory.) Using assembly 'Remittance Form' for assembly-level attributes for the target assembly. Merging assembly 'Remittance Form' into target assembly. Merging assembly 'PdfFileWriter' into target assembly. Copying 1 Win32 Resources from assembly 'Remittance Form' into target assembly. Transferring entry point 'Remittance_Form.Program.Main' from assembly 'Remittance Form' to assembly 'MyWinApp'. There were no errors reported in the target assembly's metadata. ILMerge: Writing target assembly 'D:\out\MyWinApp.exe'. AssemblyResolver: Assembly 'System' is referencing assembly 'System.Configuration'. AssemblyResolver: Attempting referencing assembly's directory. Resolved assembly reference 'System.Configuration' to 'C:\Windows\Microsoft.NET\Framework64\v2.0.50727\System.Configuration.dll'. (Used referencing Module's directory.) Location for referenced module 'gdi32.dll' is '' Location for referenced module 'Kernel32.dll' is '' Location for referenced assembly 'System.Windows.Forms' is 'C:\Windows\Microsoft.NET\Framework64\v2.0.50727\System.Windows.Forms.dll' There were no errors reported in System.Windows.Forms's metadata. Location for referenced assembly 'System' is 'C:\Windows\Microsoft.NET\Framework64\v2.0.50727\system.dll' There were no errors reported in System's metadata. Location for referenced assembly 'mscorlib' is 'C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorlib.dll' There were no errors reported in mscorlib's metadata. Location for referenced assembly 'System.Drawing' is 'C:\Windows\Microsoft.NET\Framework64\v2.0.50727\System.Drawing.dll' There were no errors reported in System.Drawing's metadata. ILMerge: Done.
请帮我解决这个问题。
答案 0 :(得分:0)
我将ILMerge命令修改为以下内容:
ilmerge D:\abc\RemittanceForm.exe D:\abc\PdfFileWriter.dll /out:D:\out\MyWinApp.exe /target:winexe /ndebug /log:D:\out\aaa.txt /targetplatform:"v4,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0"
谢谢@Magnus Grindal Bakken