Steve Michelotti

A .NET Developer's Toolbox

  Home  |   Contact  |   Syndication    |   Login
  175 Posts | 0 Stories | 944 Comments | 51 Trackbacks

News

View Steve Michelotti's profile on LinkedIn

profile for Steve Michelotti at Stack Overflow, Q&A for professional and enthusiast programmers




Google My Blog

What I'm Reading:

Shelfari: Book reviews on your book blog

Tag Cloud


Archives

Post Categories

Code

Publications

ILMerge is a utility which allows you the merge multiple .NET assemblies into a single binary assembly more for convenient distribution. Recently we ran into problems when attempting to use ILMerge on a .NET 4 project. We received the error message:

An exception occurred during merging:
Unresolved assembly reference not allowed: System.Core.
    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.GetMemberRefIndex(Member m)
    at System.Compiler.Ir2md.PopulateCustomAttributeTable()
    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)

It turns out that this issue is caused by ILMerge.exe not being able to find the .NET 4 framework by default. The answer was ultimately found here. You either have to use the /lib option to point to your .NET 4 framework directory (e.g., “C:\Windows\Microsoft.NET\Framework\v4.0.30319” or “C:\Windows\Microsoft.NET\Framework64\v4.0.30319”) or just use an ILMerge.exe.config file that looks like this:

   1:  <configuration>
   2:      <startup useLegacyV2RuntimeActivationPolicy="true">
   3:          <requiredRuntime safemode="true" imageVersion="v4.0.30319" version="v4.0.30319"/>
   4:      </startup>
   5:  </configuration>

This was able to successfully resolve my issue.

posted on Wednesday, June 02, 2010 6:51 AM

Feedback

# re: ILMerge - Unresolved assembly reference not allowed: System.Core 6/2/2010 9:56 AM Sarah Vessels
Thanks for posting this, it was just in time--I hit this problem just yesterday! Your suggestion of using the /lib parameter with ILMerge worked... sort of. Now I get " Unresolved assembly reference not allowed: Microsoft.VisualStudio.QualityTools.UnitTestFramework". Sigh, more Google searches ahead.

# re: ILMerge - Unresolved assembly reference not allowed: System.Core 6/2/2010 10:00 AM Sarah Vessels
Looks like adding /lib:"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies" fixed the UnitTestFramework unresolved assembly reference.

# re: ILMerge - Unresolved assembly reference not allowed: System.Core 6/2/2010 10:08 AM Steve
@Sarah - Keep in mind that assembly is in the C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies directory so you'd have to explicitly include that as well.

# re: ILMerge - Unresolved assembly reference not allowed: System.Core 6/2/2010 10:09 AM Steve
Looks like you already found your answer. :)

# re: ILMerge - Unresolved assembly reference not allowed: System.Core 5/13/2011 6:10 AM Maik
Thx a bunch, ran into this problem today! :)

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: