Search code examples
c#.netvisual-studio-2010.net-assemblyilmerge

ILMerge The located assembly 'X' manifest definition does not match the assembly reference


I've been searching a solution to my problem, but all the answers I find don't seem to match my problem. I'm using a ILMerge build script I found by @Contango on this question. It builds and I'm able to use the .exe created just fine.

The problem comes when I try to debug it. When I Debug instead of just building the project I get this error:

Error while trying to run project: Could not load file or assembly 'SpecSheet_Verifier' or on of its dependencies. The located assembly's manifest does not match the assembly reference. (Exception from HRESULT: 0x80131040)

'SpecSheet_Verifier' is the name of my assembly, not a .dll like most of the questions I found were asking about.

So, before I drive myself crazy trying to get this to work I wanted to check if it's even possible to debug the executable I built through ILMerge. If it is, then how would I go about doing that?

The build script I'm using: (Kudos to Contango)

"$(SolutionDir)ILMerge\ILMerge.exe" /out:"$(TargetDir)$(TargetName).all.exe" "$(TargetDir)$(TargetName).exe" "$(TargetDir)*.dll" /target:exe /targetplatform:v4,C:\Windows\Microsoft.NET\Framework64\v4.0 /wildcards
del *.dll
ren "$(TargetDir)$(TargetName).all.pdb" "$(TargetName).all.pdb.temp"
del *.pdb
ren "$(TargetDir)$(TargetName).all.pdb.temp" "$(TargetName).all.pdb"
del "$(TargetDir)$(TargetName).exe"
ren "$(TargetDir)$(TargetName).all.pdb" "$(TargetName).pdb"
ren "$(TargetDir)$(TargetName).all.exe" "$(TargetName).exe"
exit 0

Solution

  • I had this same error and was able to debug the ILMERGE'd exe by going into the project settings and make sure "Enable the Visual Studio Hosting Process" is UNCHECKED.