Creating a signed library with ILMerge exception

I am trying to create a federated version of FakeItEasy that includes Castle.Core. I read about ILMerge, and it seemed like this was the solution I needed. After downloading and creating FakeItEasy, I copied all the files I need (FakeItEasy.dll (.NET4), Castle.Core.dll (.NET4), ilmerge.exe, FakeItEasy.snk) to the same folder. Then I ran the following command:

ilmerge 
    /keyfile:FakeItEasy.snk 
    /out:..\FakeItEasy.dll 
    /t:library 
    /targetplatform:v4,C:\Windows\Microsoft.NET\Framework\v4.0.30319 
    FakeItEasy.dll Castle.Core.dll 

And got the following result:

An exception occurred during merging:                                                             
An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)                                                                                                
   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) 

If I leave "/keyfile:FakeItEasy.snk", the combined assembly will be created just fine, but that will not help me, since I need a signed version.

I also tried to specify the target platform as:

/targetplatform:v4,C:\Windows\Microsoft.NET\Framework64\v4.0.30319

but the results were the same.

+5
source share
2 answers

64- Windows 8. 32- Windows 7 . ILMerge . Visual Studio 32- , 32- Visual Studio 64- Windows 8, ILMerge, .

ILMerge.exe 
   /keyfile:public.snk 
   /targetplatform:"v4,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0" 
   /t:exe 
   /ndebug 
   /out:Result.exe Source.exe Other.dll

, .NET- ++-, An attempt was made to load a program with an incorrect format. , , , 32- 64- . - , . 64- , ILMerge 64- Visual Studio. , , 32- , 64- .

snk, , . ILMerge /delaysign. ILMerge ILMerge 32- .

ILMerge.exe 
   /keyfile:public.snk 
   /delaysign
   /targetplatform:"v4,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0" 
   /t:exe 
   /ndebug 
   /out:Result.exe Source.exe Other.dll

, , snk / ILMerge /delaysign. , , snk ILMerge 32- .

+2

, VS 2015 VS 2013 , (ILMerge ). , . , VS 2015 " ". VS 2015 , ILMerge .

0

All Articles