Search code examples
c#reportingilmerge

IL MergeGUI unresolved assembly reference not allowed


I ran into a problem. For 3 days in a row I can not solve the problem. The project needed reports so I turned my attention to NuGet Microsoft.Reporting.WinForms.v11. By adding it to the project, I can no longer collect all the dll libraries in one exe. IL Merge displays an error.

help, thanks.

IL MergeGUI error

Log IL MergeGUI

Copying 2 Win32 Resources from assembly 'AtlantCRM' into target assembly. Transferring entry point 'AtlantCRM.Program.Main' from assembly 'AtlantCRM' to assembly 'AtlantCRM'. There were no errors reported in the target assembly's metadata. ILMerge: Writing target assembly 'C:\Users\return name\Desktop\AtlantCRM.exe'. AssemblyResolver: Assembly 'AtlantCRM' is referencing assembly 'PresentationFramework'. AssemblyResolver: Attempting referencing assembly's directory. AssemblyResolver: Did not find assembly in referencing assembly's directory. AssemblyResolver: Attempting input directory. AssemblyResolver: Did not find assembly in input directory. AssemblyResolver: Attempting user-supplied directories. AssemblyResolver: No user-supplied directories. AssemblyResolver: Attempting framework directory. AssemblyResolver: Did not find assembly in framework directory. AssemblyResolver: Unable to resolve reference. (It still might be found, e.g., in the GAC.) AssemblyResolver: Assembly 'PresentationFramework' is referencing assembly 'PresentationCore'. AssemblyResolver: Attempting referencing assembly's directory. AssemblyResolver: Did not find assembly in referencing assembly's directory. AssemblyResolver: Attempting input directory. AssemblyResolver: Did not find assembly in input directory. AssemblyResolver: Attempting user-supplied directories. AssemblyResolver: No user-supplied directories. AssemblyResolver: Attempting framework directory. AssemblyResolver: Did not find assembly in framework directory. AssemblyResolver: Unable to resolve reference. (It still might be found, e.g., in the GAC.) AssemblyResolver: Assembly 'PresentationCore' is referencing assembly 'WindowsBase'. AssemblyResolver: Attempting referencing assembly's directory. AssemblyResolver: Did not find assembly in referencing assembly's directory. AssemblyResolver: Attempting input directory. AssemblyResolver: Did not find assembly in input directory. AssemblyResolver: Attempting user-supplied directories. AssemblyResolver: No user-supplied directories. AssemblyResolver: Attempting framework directory. AssemblyResolver: Did not find assembly in framework directory. AssemblyResolver: Unable to resolve reference. (It still might be found, e.g., in the GAC.) AssemblyResolver: Assembly 'PresentationFramework' is referencing assembly 'System.Xaml'. AssemblyResolver: Attempting referencing assembly's directory. AssemblyResolver: Did not find assembly in referencing assembly's directory. AssemblyResolver: Attempting input directory. AssemblyResolver: Did not find assembly in input directory. AssemblyResolver: Attempting user-supplied directories. AssemblyResolver: No user-supplied directories. AssemblyResolver: Attempting framework directory. Resolved assembly reference 'System.Xaml' to 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.Xaml.dll'. (Used framework directory.) AssemblyResolver: Assembly 'Bunifu_UI_v1.5.4' is referencing assembly 'System.Management'. AssemblyResolver: Attempting referencing assembly's directory. AssemblyResolver: Did not find assembly in referencing assembly's directory. AssemblyResolver: Attempting input directory. AssemblyResolver: Did not find assembly in input directory. AssemblyResolver: Attempting user-supplied directories. AssemblyResolver: No user-supplied directories. AssemblyResolver: Attempting framework directory. Resolved assembly reference 'System.Management' to 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.Management.dll'. (Used framework directory.) AssemblyResolver: Assembly 'System.Xml' is referencing assembly 'System.Data.SqlXml'. AssemblyResolver: Attempting referencing assembly's directory. Resolved assembly reference 'System.Data.SqlXml' to 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.Data.SqlXml.dll'. (Used referencing Module's directory.) AssemblyResolver: Assembly 'System.Data' is referencing assembly 'System.EnterpriseServices'. AssemblyResolver: Attempting referencing assembly's directory. Resolved assembly reference 'System.EnterpriseServices' to 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.EnterpriseServices.dll'. (Used referencing Module's directory.)


Solution

  • You probably don't want to hear this, but the ilmergeGUI is outdated. .net 4.6 really broke it and it has just gotten worse since. I highly recommend compiling using CMD instead. You will have much more control and understanding as to what is going on with your merge.

    Edit: sorry about not including the link. Ilmerge documentation can be found here. Sections 1 and 2 are about how to use it in your code, but section 3 is to what I was referring.

    Instructions:

    Open a Command Prompt

    If you don't have your path set in windows to find the ilmerge command, you may need to set your path every time you open a command prompt (assuming your install location is the typical location):

    SET PATH=%PATH%;C:\Program Files (x86)\Microsoft\ILMerge
    

    Then you just run your ilmerge command following the documentation I linked above.

    Example:

    ilmerge /targetplatform:v4,"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1" /out:"C:\Users\my\Documents\VerificationsMerged.dll" Verifications.dll Newtonsoft.Json.dll
    

    This example uses .netframework version 4.6.1, but you could instead point it to a different version, and then merges Verifications.dll and Newtonsoft.Json.dll together (note these are assumed to be in the current folder of your command prompt, you could instead provide an absolute path) and saves VerificationsMerged.dll to my documents folder.