New Message on dotNET User Group Hyd

Article : Assembly Linker (Al.exe .Net FrameWork Tools Series)

Reply
  Reply to Sender   Recommend Message 1 in Discussion
From: Nasha

Hi All,
 
Assembly linker is a tool which is used to create an assembly by combining one or more modules and resource files.
 
I had covered in one of previous articles as to wat are .netmodules. If have not read it here is the link to the same :
 
In simple words an .netmodule is an IL file that does not have  manifest in it .... you can say its an assembly without the manifest ... and hence a non -assembly file containing IL code.

In the yesterday's example we saw how we can create the .resources file which by itself is a binary file containing your resource data. Today we will see how we can embed or link this .resource file with other .netmodules and create an assembly
 
1) Create 2 .netmodules say Module1.netmodule and Module2.netmodule
2) Create a .resources file say MyResources.resources (as we created in yesterdays article ... please to the same for more details)
3) Now type the follwoing command to combine these modules and binary resource file into a single assembly.
 
// to create a dll.
al Module1.netmodule Module2.netmodule /embed:MyResources.resources /out:MyExecutable.dll 
 
 // to create an exe.
al Module1.netmodule  Module2.netmodule /embed:MyResources.resources /out:MyExecutable.exe /target:exe /Main:Class1.Main
 
 
If you dont want to embed the resource file then use the /link option instead of /embed option with al.exe.
 
Well if you have an want to embed or link a resource then you can compile the resource file when you are compliing the assembly with csc.exe or vbc.exe  just use /resource to embed the resource or /linkresource with the assembly.
 
You can also achieve this from VS.Net studio by including the resource file in the project and setting the Build Action of the resource type to Embedded Resource.
 
Al is mainly used by a lot of developers to create resource satellite assemblies esp for creating multilingual applications by creating resource assemblies for various cultures.
 
If only resource files are passed to Al.exe, the output file is a satellite resource assembly.
 
E.g. To create an satellite assembly for french culture
 
1) Create a file named MyResource.fr-FR.txt
2) Type your name=value resource data in it to generate the resource file
3) generate the resource file with the name of MyResource.fr-FR.resources.
4) And finally create the satellite assembly as shown below for your application
 
al /out:MyGlobApp.resources.dll /v:1.0.0.0/c:fr-FR /embed:MyResource.fr-FR.resources, Private
 
Note : Check out the Private keyword in the above command. You can use the "private" option if you want dont want other assemblies to use the embedded resource files by default it is "public".
 
5) In this command we have specified the output file name , the version of this DLL , the culture "fr-FR" which denotes french and finally we are embedding the fr-FR.resources file in MyGlobApp.resources.dll
 
6) Place this file in bin\fr-FR folder of your application and read it from the application using the ResourceManger Class.
 
There are a lot of other options that are available with AL you can view these options by typing al /? or al /help. I am enlisting a few important or frequently used ones here :
 
 
    •   /copy[right]:<text>      Copyright message
    •   /c[ulture]:<text>         Supported culture
    •   /delay[sign][+|-]          Delay sign this assembly
    •   /out:<filename>          Output file name for the assembly manifest
    •   /t[arget]:lib[rary]          Create a library
    •   /t[arget]:exe               Create a console executable
    •   /t[arget]:win[exe]        Create a Windows executable
    •   /trade[mark]:<text>     Trademark message
    •   /v[ersion]:<version>     Version (use * to auto-generate remaining numbers)
    •   /win32icon:<filename> Use this icon for the output
    •   /win32res:<filename>   Specifies the Win32 resource file
 
If you checkout the help at the end you will see this lines which show you how to go about using this tool.
 
Sources: (at least one source input is required) <filename>[,<targetfile>]
         add file to assembly
 
/embed[resource]:<filename>[,<name>[,Private]]
          embed the file as a resource in the assembly
 
/link[resource]:<filename>[,<name>[,<targetfile>[,Private]]]
           link the file as a resource to the assembly
 

-- Please post your queries and comments for my articles in the usergroup for the benefit of all. I hope this step from my end is helpful to all of us.

Regards,

Namratha (Nasha)

 

View other groups in this category.

baazee.com

Also on MSN:
Start Chatting | Listen to Music | House & Home | Try Online Dating | Daily Horoscopes

To stop getting this e-mail, or change how often it arrives, go to your E-mail Settings.

Need help? If you've forgotten your password, please go to Passport Member Services.
For other questions or feedback, go to our Contact Us page.

If you do not want to receive future e-mail from this MSN group, or if you received this message by mistake, please click the "Remove" link below. On the pre-addressed e-mail message that opens, simply click "Send". Your e-mail address will be deleted from this group's mailing list.
Remove my e-mail address from dotNET User Group Hyd.

Reply via email to