Windows Develop Bookmark and Share   
 index > Windows Forms Sample Applications > Problem with merging assemblies using ILmerge
 

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(Properties.Resources.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  Wednesday, February 11, 2009 1:58 PM
Hi Kulabhishek,

I don't really understand how does it happened.
Below is what I've done:

First, double click at Resources.resx under Properties folder.
Click at Add Resource and choose Add Existing File...
Then choose a file, for example, "Test.xml".
Remember to save Resources.resx.
After that, when you're coding, you could get "Test.xml" by Propertise.Resources.Test.

Wish this will help you.
If there's any problem, please feel free to let me know.

Best regards,
Steven Yu
Steven.Yu  Thursday, February 12, 2009 9:50 AM
Hi Steve,

Thanks for your suggestion, but the problem is bit different.

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.Resources1.dll and namespace A.B.C
Project 2: DLL with name A.B.C.Resources2.dll and namespace A.B.C
Project 3: DLL with name A.B.D.Resources3.dll and namespace A.B.D
Project 4: EXE with name X.Y.Z.ResourcesTest.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.Image = Properties.Resources.Image_Name;

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.Resources.log /t:library /copyattrs /allowdup /out:A.B.C.Resources.dll A.B.C.Resources1.dll A.B.C.Resources2.dll A.B.D.Resources3.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.Properties,
Class Resources for the A.B.C.Resources1.dll DLL is as it is : Resources
Class Resources for the A.B.C.Resources2.dll DLL is renamed to A.B.C.Resources23043.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.Properties 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
Kulabhishek  Friday, February 13, 2009 8:54 AM

You can use google to search for other answers

Custom Search

More Threads

• Get the Run time Created controls of ids
• Problem with InfoPath2007IOleCommands Sample
• Does XPander control needs the Manifest?
• SoapException
• Can't install IssueVision due to a password complexity issue?
• Assembly Cache
• Did IssueVission run on SQL Server Express ?
• "Terrarium Server Is Experiencing Difficulties" error...
• DataGridView not raising CellPainting event
• must declare the variable '@hostname'