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?
I had the same problem and managed to fix it.
Originally I generated a .PFX file to sign my assembly in Visual Studio (using the Signing tab in the project properties window). I then extracted the public key from the .PFX file into a .SNK file (using sn.exe).
When I tried to use ILMerge.exe and use the generated .SNK file I would get the "Unable to load DLL 'mscorsn.dll'"
error.
I fixed it by deleting the .PFX and generated .SNK files. I then generated a new .SNK file as follows (in VS):
<New>
This generated a new .SNK file and when I used that file with ILMerge the error disappeared.
HTH
the same issue. This answer Unable to load DLL mscorsn.dll with ILMerge helped to me.
(shortly: ilmerge requires .NET3.5 to be installed)
Add /delaysign
switch after the /keyfile
. This will do the trick.
I was pulling my hair out for 2 days straight trying to solve this on my machine and finally found the answer. Nothing worked from any of the suggestions pasted here. I finally searched the IlMerge github and found a post regarding the possible connection to MachineKeys folder not having proper permissions.
If anyone of You has the same issue and nothing works, please go to this directory: C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys
And set the permissions to Read AND Write for MachineKeys folder:
Permissions on MachineKeys folder
This link helped me in setting the properly:
Removing the /keyfile argument worked. Well signing is another issue I guess. Don't know how to solve this but at least it worked this way.
User contributions licensed under CC BY-SA 3.0