473,386 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Assemblys vs. Modules ?

Hello,

I’m in the process of reading "Inside Microsft .NET IL Assembler" by Serge
Lidin to gain a better understanding of my .NET code at a lower (IL) level.
There is one concept that I am having trouble grasping, however: Assemblies
versus modules and how they relate to one another. From what I can tell,
assemblies contain one or multiple modules, but I’m not sure of this. I know
that your .NET compiled code can end up in a DLL or an EXE file. Is it a fair
statement that the DLL or EXE file is the actual assembly? I ask this because
of the following statement from the text:

“An assembly is basically a deployment unit, a building block of a managed
application. Assemblies are reusable, allowing different applications to use
the same assembly.”

In my mind, a deployment unit is a file. Please correct me if I’m wrong here.

Another statement that I could use clarification on:

“Managed .NET applications are called assemblies.. The managed executables
are referred to as modules. You can create single-module assemblies and
multimodule assemblies. As illustrated in Figure 1-1, each assembly contains
one prime module, which carries the assembly identity information in its
metadata.”

“Applications” are assemblies? What exactly is an application? Is it code
that can be executed? Is it the actual file?

And “managed executables” are modules? Again, is this executable an actual
..exe file?

Lastly, under the description of “Module Metadata Table and Declaration:”
"Name (offset in the #Strings stream) The module name, which is the same as
the name of the executable file with its extension but without a path. The
length should not exceed 512 characters, counting the zero terminator."

So, the module name has the same name as the executable file. Are they
therefore analogus? If so, does the assembly somehow supersede the entire
file? Any clarification would be much appreciated. Thank you very much...

-Ben
Nov 22 '05 #1
5 1615
Ben,

Yes, .exe's and .dll's are assemblies. You first create modules - one
or more, which you can build to assemblies (.exe or .dll).

Application - is a set of .exe's (one or more) and .dlls (you may have
single .exe too) which solves specific problem :)

Module <> .exe. Module is called where you write you source code, when
is compiled, the resulting file is .exe or .dll.

Regards,

Philip.

Nov 22 '05 #2
Philip Hristov <ph********@gmail.com> wrote:
Yes, .exe's and .dll's are assemblies. You first create modules - one
or more, which you can build to assemblies (.exe or .dll).

Application - is a set of .exe's (one or more) and .dlls (you may have
single .exe too) which solves specific problem :)

Module <> .exe. Module is called where you write you source code, when
is compiled, the resulting file is .exe or .dll.


I'm not sure I quite agree with you - you seem to be regarding a module
as a source level object, rather than a compiled object. In .NET
terminology a module is one part (possibly the only part) of an
assembly - in compiled form.

From the docs for the Module class:

<quote>
A module is a portable executable file of type .dll or .exe consisting
of one or more classes and interfaces. There may be multiple namespaces
contained in a single module, and a namespace may span multiple
modules.

One or more modules deployed as a unit compose an assembly.
</quote>

and from partition I of the CLI spec:

<quote>
A module is a single file containing executable content in the format
specified in Partition II.
</quote>

This isn't the same thing as a VB.NET Module, just to throw a further
spanner in the works.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 22 '05 #3
Jon,

I thought that is a VB module. :)

Regards,

Philip.

Nov 22 '05 #4
Hi Jon,

Thanks for your answer. I could use a bit more clarification, though. From
what I can tell, there is reallyi no difference between a module and an
assembly except an assembly has a manifest as well. Is this correct? If so, I
would assume that the assembly linker tool al.exe would simply add a manifest
to a module to produce an assembly. In my experimentation this was not the
case, though.

I first compiled a .cs file to a .exe with csc. Everything worked fine.

Next, for comparison, I compiled the .cs file with .csc but set the target
to module, and got test.netmodule. Then, I fed that to al.exe with the target
set to an exe. I assumed that I had manually taken the same steps that csc
would do in one swoop to produce an exe. The newly gen'd exe would run
correctly, but it seems that it used the .netmodule as an external reference
(or dependence). When I removed the .netmodule file and tried to run the exe,
I got:

Unhandled Exception: System.IO.FileNotFoundException: File or assembly name
test.netmodule, or one of its dependencies, was not found.
File name: "test.netmodule"
at __EntryPoint()

I checked under ildasm comparing the two exes, and they were in fact
different. al.exe seemed to generate a new method called __EntryPoint() that
would call the external .netmodule. The one generated entirely with csc.exe
actually contained my main method within the exe. I wonder if there is
another way to use al.exe that does something more analogus to static linking
(if the analogy is apt at all). I'm guessing there is a way because csc does
result in a file that has no external depndencies. Everything's inside. This
further leads me to wonder if it's feasible to distribute .netmodule files if
they can be linked into and why that isn't a common practice.

Thanks...

-Ben

"Jon Skeet [C# MVP]" wrote:
Philip Hristov <ph********@gmail.com> wrote:
Yes, .exe's and .dll's are assemblies. You first create modules - one
or more, which you can build to assemblies (.exe or .dll).

Application - is a set of .exe's (one or more) and .dlls (you may have
single .exe too) which solves specific problem :)

Module <> .exe. Module is called where you write you source code, when
is compiled, the resulting file is .exe or .dll.


I'm not sure I quite agree with you - you seem to be regarding a module
as a source level object, rather than a compiled object. In .NET
terminology a module is one part (possibly the only part) of an
assembly - in compiled form.

From the docs for the Module class:

<quote>
A module is a portable executable file of type .dll or .exe consisting
of one or more classes and interfaces. There may be multiple namespaces
contained in a single module, and a namespace may span multiple
modules.

One or more modules deployed as a unit compose an assembly.
</quote>

and from partition I of the CLI spec:

<quote>
A module is a single file containing executable content in the format
specified in Partition II.
</quote>

This isn't the same thing as a VB.NET Module, just to throw a further
spanner in the works.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 22 '05 #5
Ben R. <Be**@discussions.microsoft.com> wrote:
Thanks for your answer. I could use a bit more clarification, though. From
what I can tell, there is reallyi no difference between a module and an
assembly except an assembly has a manifest as well. Is this correct?
Not quite - an assembly can contain more than one module.
If so, I
would assume that the assembly linker tool al.exe would simply add a manifest
to a module to produce an assembly. In my experimentation this was not the
case, though.

I first compiled a .cs file to a .exe with csc. Everything worked fine.

Next, for comparison, I compiled the .cs file with .csc but set the target
to module, and got test.netmodule. Then, I fed that to al.exe with the target
set to an exe. I assumed that I had manually taken the same steps that csc
would do in one swoop to produce an exe. The newly gen'd exe would run
correctly, but it seems that it used the .netmodule as an external reference
(or dependence). When I removed the .netmodule file and tried to run the exe,
I got:

Unhandled Exception: System.IO.FileNotFoundException: File or assembly name
test.netmodule, or one of its dependencies, was not found.
File name: "test.netmodule"
at __EntryPoint()
Indeed. That's created an assembly with a .exe containing just the
manifest, which tells it that it needs test.netmodule as part of the
assembly.
I checked under ildasm comparing the two exes, and they were in fact
different. al.exe seemed to generate a new method called __EntryPoint() that
would call the external .netmodule. The one generated entirely with csc.exe
actually contained my main method within the exe. I wonder if there is
another way to use al.exe that does something more analogus to static linking
(if the analogy is apt at all). I'm guessing there is a way because csc does
result in a file that has no external depndencies. Everything's inside. This
further leads me to wonder if it's feasible to distribute .netmodule files if
they can be linked into and why that isn't a common practice.


Multi-module assemblies are very rare, to be honest - there's rarely
any use for them, basically.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 22 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Nick Coghlan | last post by:
Anyone playing with the CPython interpreter's new command line switch might have noticed that it only works with top-level modules (i.e. scripts that are directly on sys.path). If the script is...
15
by: Nick Coghlan | last post by:
Python 2.4's -m command line switch only works for modules directly on sys.path. Trying to use it with modules inside packages will fail with a "Module not found" error. This PEP aims to fix that...
7
by: Jorgen Grahn | last post by:
I have a set of tests in different modules: test_foo.py, test_bar.py and so on. All of these use the simplest possible internal layout: a number of classes containing test*() methods, and the good...
5
by: Ben R. | last post by:
Hello, I’m in the process of reading "Inside Microsft .NET IL Assembler" by Serge Lidin to gain a better understanding of my .NET code at a lower (IL) level. There is one concept that I am...
4
by: Misto . | last post by:
Hi folks! Short: There is a way to dumplicate a module ? I tried copy.deepcopy(module) but hangs with an error (also with standard modules ).. The only solution that I have by now is...
2
by: James Buchanan | last post by:
Hi group, I'm preparing Python 2.4.2 for the upcoming Minix 3.x release, and I have problems with make. configure runs fine and creates the makefile, but right at the end ends with an error...
7
by: Lauren Quantrell | last post by:
At running the risk of asking how big is too big... Is there a rule of thumb or a best practice that says I may have too many modules? I currently have a Access2K app with about 30 code modules,...
3
by: Ren P. | last post by:
Hello, i have a little application that search into a special folder to assemblys. Founded assembly would be load by Assembly.LoadFrom(). Is there a way to load only assemblys that are from my...
13
by: Robin Haswell | last post by:
Hey people I'm an experience PHP programmer who's been writing python for a couple of weeks now. I'm writing quite a large application which I've decided to break down in to lots of modules...
3
by: Mohamed Yousef | last post by:
Hello , The problem I'm asking about is how can imported modules be aware of other imported modules so they don't have to re-import them (avoiding importing problems and Consicing code and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.