.netilmergesnk

mscorsn.dll doesn't load when using ILMerge


I'm using the following command on cmd with Administrator priviliges:

ILMerge.exe  /wildcards /log:ILMerge.log /allowdup 
             /targetplatform:"v4,C:\Windows\Microsoft.NET\Framework\v4.0.30319" 
             /lib:"C:\SDK2016\SDK2016\Bin" 
             /lib:"packages\Microsoft.CrmSdk.Extensions.7.1.0.1\lib\net45" 
             /lib:"packages\log4net.2.0.5\lib\net45-full" 
             /keyfile:"Tools\Snk\XXX.snk" 
             /out:"c:\XXXALLMERGED.dll" 
             "c:\proj\alldlls\*.dll"

And I'm getting the following error at the end of the log file:

An exception occurred during merging:
Unable to load DLL 'mscorsn.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at System.Compiler.Writer.MscorsnStrongNameSignatureGeneration(String wszFilePath, String wszKeyContainer, Byte[] pbKeyBlob, Int32 cbKeyBlob, IntPtr ppbSignatureBlob, IntPtr pcbSignatureBlob)
   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)

Since my targetframework is v4 and my folder is "v4,C:\Windows\Microsoft.NET\Framework\v4.0.30319", I checked if mscorsn.dll exists there; and it exists.

So, what can be the problem? Can you please help?


Solution

  • the same issue. This answer Unable to load DLL mscorsn.dll with ILMerge helped to me.

    (shortly: ilmerge requires .NET3.5 to be installed)