English 中文(简体)
ILMerge DLL: Assembly not merged in correctly, still listed as an external reference
原标题:

In the build process for a .NET C# tool, I have been using ILMerge to merge the assemblies into a single exe.

I added a new class library recently, and now the ILMerge is failing. I have remembered to tell it to merge in the new DLL!

It is now giving me this error, which I don t really understand:

ILMerge.Merge: The assembly DataObjects was not merged in correctly. It is still listed as an external reference in the target assembly.

All of the assembly references I have done using project references, and it has not failed in the past.

Can anyone explain this error for me, or suggest a workaround please?

最佳回答

I had to use the /closed argument. According to the official docs:

Closed

When this is set before calling Merge, then the "transitive closure" of the input assemblies is computed and added to the list of input assemblies. An assembly is considered part of the transitive closure if it is referenced, either directly or indirectly, from one of the originally specified input assemblies and it has an external reference to one of the input assemblies, or one of the assemblies that has such a reference. Complicated, but that is life...

问题回答

I got a similar error message when trying to publish a web app that merged all outputs to a single assembly:

An error occurred when merging assemblies: ILMerge.Merge: The target assembly lists itself as an external reference.

This happens if the assembly name you are merging to matches the assembly name of the web application under Properties > Application. Changing the output assembly name should fix it.

I got this error and it pointed to the Microsoft.Xrm.Sdk reference which I was merging into the single dll. The problem was fixed when I set another reference, Microsoft.Xrm.Sdk.Deployment to merge into the dll as well. Funny thing is in a separate project I had the 1st reference merging and the 2nd deployment dll not merging & it did not complain at all.

This is exactly @HughJeffner s answer as an image. It took me a while & some tries to replicate the instructions.

Locations of the fields that should NOT be identical.

While publishing select Do not merge from configure and than publish the Project

I got this error for System.Memory.dll which was odd. In the context of merging and deploying a Dynamics CRM Plugin dll.

I actually just ignored it and deployed my Merged DLL... trusting that Dynamics CRM s Plugin context would provide it when it s deployed.

The MergedPlugin.dll was still built even with the error about System.Memory.dll. So I just deployed the Plugin to CRM, and it worked.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签