473,569 Members | 2,402 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1633
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********@gma il.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.co m>
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.FileN otFoundExceptio n: 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********@gma il.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.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 22 '05 #5
Ben R. <Be**@discussio ns.microsoft.co m> 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.FileN otFoundExceptio n: 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.co m>
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
1941
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 inside a package, the invocation will fail with a "Module not found" error. This PEP is aimed at fixing that :) Cheers, Nick.
15
2571
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 for Python 2.5. Previously, posting of a draft version of the PEP to python-dev and python-list didn't actually generate any responses. I'm not...
7
2061
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 old lines at the end: if __name__ == "__main__": unittest.main() This is great, because each of the modules are runnable, and I can select...
5
373
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 having trouble grasping, however: Assemblies versus modules and how they relate to one another. From what I can tell, assemblies contain one or...
4
1745
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 creating two files and importing them.
2
2030
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 about a circular dependency in Modules/signalmodule.o. I'm new to makefiles and makefile rules, so I can understand what this means, but I don't...
7
4293
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, plus of course the modules associated with the forms themselves. My practice has been to create a seperate module to handle specific groupings...
3
1213
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 company? I would not that 3th party assemblys are loaded. So if i copy an assembly into this folder on next restart the new assembly should be load...
13
2334
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 (replacement for PHP's include() statement). My problem is, in PHP if you open a database connection it's always in scope for the duration of the...
3
1815
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 imports ) Take Example :- in A.py :- import B print dir() # no problems we can see B which contain re module and C module
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main...
0
7618
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7926
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7679
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5223
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2117
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1228
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.