ILMerge and XamlGeneratedNamespace .GeneratedInternalTypeHelper

If you use ILMerge on a WPF project, you might be in for a shock if you add a WPF window to a library used by the project. ILMerge will refuse to proceed with a message looking like this:

    ILMerge.Merge: ERROR!!: Duplicate type
        found in assembly 'YourAssembly'.

Using a free tool published by my company, it is now possible to work around this problem. Read on for details.

The reason why this problem occurs is that the XAML compiler creates a type named XamlGeneratedNamespace.GeneratedInternalTypeHelper in every assembly where XAML is used. By adding a WPF window to a library, you end up with a type with this name in both your main project and the library. Hence, all you need to fix this problem is rename the type to something else.

Renaming the type

Rummage type renamer is a free tool distributed with Rummage which can be used to rename a type in an assembly. Detailed instructions are available on the linked page, however all you need is to run the following command:

"C:\Program Files\Rummage\RummageTypeRenamer.exe"
      -f XamlGeneratedNamespace.GeneratedInternalTypeHelper
      -t XamlHelper1 YourAssembly.dll YourAssembly.dll

That's it! You can now ILMerge these assemblies. If you have more than two assemblies with this type, simply run this command on each one, using a unique name after the -t option in each case (for example, XamlHelper1, XamlHelper2, etc).