Why I can't ILMerge Zxing?

160 Views Asked by At

Trying to ILMerge project that contains Zxing.NET package:

"C:\Program Files (x86)\Microsoft\ILMerge\ILMerge.exe" CommandLineDecoder.exe zxing.dll zxing.presentation.dll  /out:CommandLineDecoder2.exe

Got error:

An exception occurred during merging:
Unresolved assembly reference not allowed: System.Numerics.
   at System.Compiler.Ir2md.GetAssemblyRefIndex(AssemblyNode assembly)
   at System.Compiler.Ir2md.GetTypeRefIndex(TypeNode type)
   at System.Compiler.Ir2md.VisitReferencedType(TypeNode type)
   at System.Compiler.Ir2md.VisitReferencedType(TypeNode type)
   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)

Why I'm getting this error? What does it means? How to fix that?

1

There are 1 best solutions below

0
On

From https://github.com/dotnet/ILMerge:

ILMerge runs in the v4.0 .NET Runtime, but it is also able to merge assemblies from other framework versions using the /targetplatformoption. Please see the documentation. (However, it can merge PDB files only for v2 (and later) assemblies.)

I expect you are using a class from System.Numerics that is not available in v4.0 and you need to change the target platform, either in code:

public void SetTargetPlatform(string platform, string dir);

or using the command line:

/targetplatform:version,platformdirectory

Where the first argument is the platform version, and the second argument is the directory in which mscorlib.dll is to be found.

The relevant section of the documentation:

https://github.com/dotnet/ILMerge/blob/master/ilmerge-manual.md#221-settargetplatform