Problem with merging assemblies using ILmerge

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kulabhishek
    New Member
    • Dec 2008
    • 26

    Problem with merging assemblies using ILmerge

    Hello,

    I have used ILMerge tool to merge the multiple dlls into one. The dlls were merged successfully and the out file was also dll.
    But when i am using this dll with other application, it is giving me error with Resources.

    The resources are there in same assembly, with build action None.

    Like :
    The resource file is Expression.xml in Resources folder with build action None.
    Then after merging the dlls, with new dll I am getting exception with the line
    TextReader reader = new StringReader(Pr operties.Resour ces.Expression) ;

    So the application is not able to find the resource Expression, but if I check the dll in the Reflector, the resource is there.

    Can anyone tell me what to do with this problem?

    Regards
    Abhishek
  • kulabhishek
    New Member
    • Dec 2008
    • 26

    #2
    Actually problem is, the application using the merged dll is not able to find the resources inside merged DLLs.

    Let me explain the problem with the help of a demo project.

    Here is what I have done in demo project

    Inside one solution, I have 4 projects.

    Project 1: DLL with name A.B.C.Resources 1.dll and namespace A.B.C
    Project 2: DLL with name A.B.C.Resources 2.dll and namespace A.B.C
    Project 3: DLL with name A.B.D.Resources 3.dll and namespace A.B.D
    Project 4: EXE with name X.Y.Z.Resources Test.exe and namespace X.Y.Z . This project has the above three projects added as
    references.

    Each of the first three projects contains :
    A. Image resource (The resources are added the way you told).
    B. One form and one button added to it.

    I am simply setting the image for the button inside constructor of each project, as :

    Button_Name.Ima ge = Properties.Reso urces.Image_Nam e;

    The fourth project has three buttons, each for one DLL and I am calling appropriate constructor on button click event.

    Now, if i use three DLLs separately : everything works fine.

    If I merge three dlls with command :

    ILMerge /log:A.B.C.Resou rces.log /t:library /copyattrs /allowdup /out:A.B.C.Resou rces.dll A.B.C.Resources 1.dll A.B.C.Resources 2.dll A.B.D.Resources 3.dll

    and

    use the merged DLL in the 4th project : The image for button of the 2nd DLL is not visible (Resources not found).

    Observations and Findings :

    1. After merging, the Resource class is getting renamed by the ILMerge for the 2nd DLL. This happens because the namespace of
    the first and second DLL is the same.

    Ex : I saw the merged DLL inside Reflector, It shows, inside namespace A.B.C.Propertie s,
    Class Resources for the A.B.C.Resources 1.dll DLL is as it is : Resources
    Class Resources for the A.B.C.Resources 2.dll DLL is renamed to A.B.C.Resources 23043.Resources

    2. For the 3rd DLL everything works fine, as it has different namespace.

    3. If I change the namespace for the 3rd DLL to A.B.C and merge the DLLs, the image for buttons of the 2nd as well as 3rd DLLs are
    missing.

    4. If I use the different namespace for each DLL and merge them and use, everything works fine.

    5. So, basically I think this is due to renaming of the Resource class in the A.B.C.Propertie s namespace.

    Is there any way to solve this, without changing the namespaces?? Because I want all the dlls to have the same namespace.

    Is there any way to stop renaming by ILMerge?

    Regards
    Abhishek

    Comment

    Working...