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

  • Thread starter Namratha Shah \(Nasha\)
  • Start date
N

Namratha Shah \(Nasha\)

Hi All,

Assembly linker is a tool which is used to create an assembly by combining
one or more .netmodules and resource files.

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 :


a.. /copy
:<text> Copyright message
b.. /c[ulture]:<text> Supported culture
c.. /delay[sign][+|-] Delay sign this assembly
d.. /out:<filename> Output file name for the assembly
manifest
e.. /t[arget]:lib[rary] Create a library
f.. /t[arget]:exe Create a console executable
g.. /t[arget]:win[exe] Create a Windows executable
h.. /trade[mark]:<text> Trademark message
i.. /v[ersion]:<version> Version (use * to auto-generate remaining
numbers)
j.. /win32icon:<filename> Use this icon for the output
k.. /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)​
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top