'ILMerge error: Key needs to be greater than 0
We have a step on our build server that merges our DLLs into one for easy transport.
In our QA environment, we are getting the following error when running ILMerge
An exception occurred during merging:
Key needs to be greater than 0.
Parameter name: key
at System.Compiler.TrivialHashtable.get_Item(Int32 key)
at System.Compiler.Ir2md.GetTypeSpecIndex(TypeNode type)
at System.Compiler.Ir2md.GetMemberRefIndex(Member m)
at System.Compiler.Ir2md.GetMethodToken(Method m)
at System.Compiler.Ir2md.VisitConstruct(Construct cons)
at System.Compiler.Ir2md.VisitAssignmentStatement(AssignmentStatement assignment)
at System.Compiler.Ir2md.VisitBlock(Block block)
at System.Compiler.Ir2md.VisitBlock(Block block)
at System.Compiler.Ir2md.VisitMethodBody(Method method)
at System.Compiler.Ir2md.VisitMethod(Method method)
at System.Compiler.Ir2md.VisitClass(Class Class)
at System.Compiler.Ir2md.VisitModule(Module module)
at System.Compiler.Ir2md.SetupMetadataWriter(String debugSymbolsLocation)
at System.Compiler.Ir2md.WritePE(Module module, String debugSymbolsLocation, BinaryWriter writer)
at System.Compiler.Writer.WritePE(String location, Boolean writeDebugSymbols, Module module, Boolean delaySign, String keyFileName, String keyName)
at System.Compiler.Writer.WritePE(CompilerParameters compilerParameters, Module module)
at ILMerging.ILMerge.Merge()
at ILMerging.ILMerge.Main(String[] args)
Any ideas how this can be fixed? We have too much code and too many DLLs for it to be useful for me to provide any more info about what DLLs we're trying to merge.
The code being merged was branched off of our development line this morning- the code is identical to the development line, which is able to ILMerge just fine.
The merge error is occurring on our local machines as well as our build server.
I know this isn't a lot to go on, but it's all I've got!
After building the code in Release mode, IL merge works properly.
Solution 1:[1]
My answer is a bit dated, but I've met the same issue, maybe it helps someone.
I've had the exception, having ILMerge action in post build event in Visual Studio. I am aware how stupid it sounds but the solution was replacing all delegates, Action and Func<> with normal methods. The problem also disappeared when building in release mode
Solution 2:[2]
Try my ILMerge fork at https://github.com/isukces/ILMerge . It never crashes with a negative key exception.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Piotr St?clik |
