ILMerge can't run new exe

1

UPDATED: Solution: Check @Matthew solution in comments.

Wanted result: WPF Application exe that can run as Standalone, copy to usb and run it without installing anything.

What's happening: A new exe file is created but when double click on the file nothing happens.

Editor: Visual Studio 2015

ILMerge: Nuget package, 2.14.1208

I've edited *.csproj and added post build action

<Target Name="AfterBuild" Condition=" '$(Configuration)' == 'Release' ">
    <CreateItem Include="@(ReferenceCopyLocalPaths)" Condition="'%(Extension)'=='.dll'">
        <Output ItemName="AssembliesToMerge" TaskParameter="Include" />
    </CreateItem>
    <PropertyGroup>
        <ReferenceAssemblies>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1</ReferenceAssemblies>
        <MergedAssembly>$(ProjectDir)publish\MERGED_ASSEMBLY_NAME.exe</MergedAssembly>
        <ExecString>&quot;$(SolutionDir)\packages\ILMerge.2.14.1208\tools\ILMerge.exe&quot; /out:&quot;$(MergedAssembly)&quot; /internalize /allowDup /targetplatform:v4,&quot;$(ReferenceAssemblies)&quot; &quot;@(IntermediateAssembly)&quot; @(AssembliesToMerge->'&quot;%(FullPath)&quot;', ' ')</ExecString>
    </PropertyGroup>
    <Message Importance="high" Text="Executing ILMerge...with target platform from $(ReferenceAssemblies)" />
    <Message Importance="high" Text="$(ExecString)" />
    <Exec Command="$(ExecString)" />
</Target>

This will run ilmerge.exe, if I copy this and run in Command Prompt it executes with no error.

"D:\Visual Studio\DrawTool\\packages\ILMerge.2.14.1208\tools\ILMerge.exe" /out:"D:\Visual Studio\DrawTool\MyDrawTool\publish\MERGED_ASSEMBLY_NAME.exe" /internalize /allowDup /targetplatform:v4,"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1" "obj\Release\MyDrawTool.exe" "D:\Visual Studio\DrawTool\packages\HtmlAgilityPack.1.4.9\lib\Net45\HtmlAgilityPack.dll" "D:\Visual Studio\DrawTool\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll" "D:\Visual Studio\DrawTool\Utils\bin\Release\Utils.dll" "D:\Visual Studio\DrawTool\packages\Extended.Wpf.Toolkit.2.6\lib\net40\Xceed.Wpf.AvalonDock.dll" "D:\Visual Studio\DrawTool\packages\Extended.Wpf.Toolkit.2.6\lib\net40\Xceed.Wpf.AvalonDock.Themes.Aero.dll" "D:\Visual Studio\DrawTool\packages\Extended.Wpf.Toolkit.2.6\lib\net40\Xceed.Wpf.AvalonDock.Themes.Metro.dll" "D:\Visual Studio\DrawTool\packages\Extended.Wpf.Toolkit.2.6\lib\net40\Xceed.Wpf.AvalonDock.Themes.VS2010.dll" "D:\Visual Studio\DrawTool\packages\Extended.Wpf.Toolkit.2.6\lib\net40\Xceed.Wpf.DataGrid.dll" "D:\Visual Studio\DrawTool\packages\Extended.Wpf.Toolkit.2.6\lib\net40\Xceed.Wpf.Toolkit.dll" "D:\Visual Studio\DrawTool\packages\Extended.Wpf.Toolkit.2.6\lib\net40\de\Xceed.Wpf.AvalonDock.resources.dll" "D:\Visual Studio\DrawTool\packages\Extended.Wpf.Toolkit.2.6\lib\net40\es\Xceed.Wpf.AvalonDock.resources.dll" "D:\Visual Studio\DrawTool\packages\Extended.Wpf.Toolkit.2.6\lib\net40\fr\Xceed.Wpf.AvalonDock.resources.dll" "D:\Visual Studio\DrawTool\packages\Extended.Wpf.Toolkit.2.6\lib\net40\hu\Xceed.Wpf.AvalonDock.resources.dll" "D:\Visual Studio\DrawTool\packages\Extended.Wpf.Toolkit.2.6\lib\net40\it\Xceed.Wpf.AvalonDock.resources.dll" "D:\Visual Studio\DrawTool\packages\Extended.Wpf.Toolkit.2.6\lib\net40\pt-BR\Xceed.Wpf.AvalonDock.resources.dll" "D:\Visual Studio\DrawTool\packages\Extended.Wpf.Toolkit.2.6\lib\net40\ro\Xceed.Wpf.AvalonDock.resources.dll" "D:\Visual Studio\DrawTool\packages\Extended.Wpf.Toolkit.2.6\lib\net40\ru\Xceed.Wpf.AvalonDock.resources.dll" "D:\Visual Studio\DrawTool\packages\Extended.Wpf.Toolkit.2.6\lib\net40\sv\Xceed.Wpf.AvalonDock.resources.dll" "D:\Visual Studio\DrawTool\packages\Extended.Wpf.Toolkit.2.6\lib\net40\zh-Hans\Xceed.Wpf.AvalonDock.resources.dll"

Now the files MERGED_ASSEMBLY_NAME.exe and MERGED_ASSEMBLY_NAME.pdb is created in publish folder. But when I'm trying to run it nothing happens.

Looking in the Event Viewer and found these errors that I think is for when I'm trying to start the new exe file.

Application: MERGED_ASSEMBLY_NAME.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileNotFoundException
   at System.Reflection.RuntimeAssembly._nLoad(System.Reflection.AssemblyName, System.String, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, System.Threading.StackCrawlMark ByRef, IntPtr, Boolean, Boolean, Boolean)
   at System.Reflection.RuntimeAssembly.nLoad(System.Reflection.AssemblyName, System.String, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, System.Threading.StackCrawlMark ByRef, IntPtr, Boolean, Boolean, Boolean)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(System.Reflection.AssemblyName, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, System.Threading.StackCrawlMark ByRef, IntPtr, Boolean, Boolean, Boolean)
   at System.Reflection.Assembly.Load(System.Reflection.AssemblyName)
   at System.Windows.Navigation.BaseUriHelper.GetLoadedAssembly(System.String, System.String, System.String)
   at MS.Internal.AppModel.ResourceContainer.GetResourceManagerWrapper(System.Uri, System.String ByRef, Boolean ByRef)
   at MS.Internal.AppModel.ResourceContainer.GetPartCore(System.Uri)
   at System.IO.Packaging.Package.GetPartHelper(System.Uri)
   at System.IO.Packaging.Package.GetPart(System.Uri)
   at System.Windows.Application.GetResourceOrContentPart(System.Uri)
   at System.Windows.Application.LoadComponent(System.Object, System.Uri)
   at DrawTools.App.InitializeComponent()
   at DrawTools.App.Main()



Faulting application name: MERGED_ASSEMBLY_NAME.exe, version: 1.0.0.0, time stamp: 0x56f2a475
Faulting module name: KERNELBASE.dll, version: 10.0.10240.16683, time stamp: 0x56ad9410
Exception code: 0xe0434352
Fault offset: 0x000b3fc8
Faulting process id: 0x2e60
Faulting application start time: 0x01d1850e83b32550
Faulting application path: D:\Visual Studio\SortDrawTool\MyDrawTools\publish\MERGED_ASSEMBLY_NAME.exe
Faulting module path: C:\Windows\SYSTEM32\KERNELBASE.dll
Report Id: 29963024-3600-4dd4-8700-33b9f6d9fb37
Faulting package full name: 
Faulting package-relative application ID: 


Fault bucket 129052204427, type 5
Event Name: CLR20r3
Response: Not available
Cab Id: 0

Problem signature:
P1: MERGED_ASSEMBLY_NAME.exe
P2: 1.0.0.0
P3: 56f2a475
P4: mscorlib
P5: 4.6.1055.0
P6: 563c0eac
P7: 40fd
P8: 0
P9: System.IO.FileNotFoundException
P10: 

Attached files:
C:\Users\frbafs01\AppData\Local\Temp\WER6D6E.tmp.WERInternalMetadata.xml
C:\Users\frbafs01\AppData\Local\Temp\WER7697.tmp.appcompat.txt
C:\ProgramData\Microsoft\Windows\WER\Temp\WER76D6.tmp.dmp
C:\Users\frbafs01\AppData\Local\Temp\WER7948.tmp.WERDataCollectionFailure.txt
C:\ProgramData\Microsoft\Windows\WER\ReportQueue\AppCrash_MERGED_ASSEMBLY__46cc5e5a6a376272b10de20c482b0dc4fa7ffcf_ee2c95da_cab_3fc07964\memory.hdmp
WERGenerationLog.txt

These files may be available here:
C:\ProgramData\Microsoft\Windows\WER\ReportQueue\AppCrash_MERGED_ASSEMBLY__46cc5e5a6a376272b10de20c482b0dc4fa7ffcf_ee2c95da_cab_3fc07964

Analysis symbol: 
Rechecking for solution: 0
Report Id: 29963024-3600-4dd4-8700-33b9f6d9fb37
Report Status: 16396
Hashed bucket: 6c9b4e91e20e53298c770adb3262c861

Note: If I remove /allowDup I get this error

An exception occurred during merging:
ILMerge.Merge: ERROR!!: Duplicate type 'XamlGeneratedNamespace.GeneratedInternalTypeHelper' found in assembly 'Xceed.Wpf.DataGrid'. Do you want to use the /allowDup option?
   at ILMerging.ILMerge.MergeInAssembly(AssemblyNode a, Boolean makeNonPublic, Boolean targetAssemblyIsComVisible)
   at ILMerging.ILMerge.Merge()
   at ILMerging.ILMerge.Main(String[] args)
c#
wpf
ilmerge
asked on Stack Overflow Mar 23, 2016 by roady • edited Jan 9, 2017 by patridge

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0