I developed my first winform application in c# on .net 4.0. The compiled output has a .exe and a .dll file. I checked that the executable is running fine before merging. I merged these two files using ILMerge. I am using ILmerge for the first time. So I must have made some mistake somewhere, but I can't resolve this issue. I got a single executable file without any error. But upon opening the result file, it is getting crashed.
Windows produced these error details on crashing of the application:
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
I installed the ILMerge and used the following commands in the cmd from the location of ILMerge to create the merged .exe file.
ilmerge D:\abc\RemittanceForm.exe D:\abc\PdfFileWriter.dll /out:D:\out\MyWinApp.exe /target:winexe /ndebug /log:D:\out\aaa.txt
The log files content is as follows:
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.
Please help me to solve this issue.