Entry
C#: Project: File: Multiple: Compile: Assembly: What is an assembly? [assemblies / package / class]
Dec 14th, 2003 06:00
Knud van Eeden,
----------------------------------------------------------------------
--- Knud van Eeden --- 26 September 2003 - 01:16 am ------------------
C#: Project: File: Multiple: Compile: Assembly: What is an assembly?
[assemblies / package / class]
---
Assemblies are .exes or .dlls generated from compiling a project of
files.
---
You know that a C# application is created by compiling a "cs" file into
an "exe" file.
This "exe" file can then be executed on any computer which supports
.NET.
You can choose to put all of your class definitions into a single "cs"
file.
You then compile it then like this:
csc MySourceCode.cs
However it is also possible to split your program across multiple "cs"
files.
You can then for example put each class in a separate file.
Separating your source code like this do not change the relationship
between your classes and does not change your program's functionality.
However, it can make it easier to manage a large development project.
If your program is separated into multiple cs files you must compile
your application this way:
csc myfilename1.cs myfilename2.cs myfilename3.cs
For this to work, at least one of your "cs" files needs to have the
starting class with a Main() method.
By default, the resulting "exe" file takes its name from the file that
contains the Main() method. You can change this by using the "out"
option:
csc myfilename1.cs myfilename2.cs myfilename3.cs /out:myapplicationname
Now the program will be named
myapplicationname
An exe file generated by the C# compiler is not quite the same as a
traditional exe file found in Windows.
In the .NET world this "exe" is called an "assembly" - because the file
is actually an assembly of multiple parts.
At a minimum, an assembly is made up of Microsoft intermediate language
code (generated from the cs files) plus a manifest.
The manifest describes the contents of the assembly.
The manifest also contains the assembly's name and version.
An assembly can even include resources like jpegs, bitmaps and icons.
Microsoft offers several tools for managing assemblies.
If you use Visual Studio, you will be able to see all the components
that make up your assembly.
---
[Internet: source: http://www.joegrip.com/csharp-course.html]
---
The .NET runtime uses the configurable attributes and versioning rules
built into assemblies to greatly simplify deployment - no more hacking
the registry - just copy the assembly into a directory and it goes.
---
Assemblies also form a type-boundary to deal with type-name collisions,
to the extent that multiple versions of an assembly can co-exist in the
same process.
---
Each file can contain multiple classes and multiple namespaces.
---
A namespace may also be spread across several assemblies, so there is
high level of freedom with this system.
---
[Internet: source:
http://genamics.com/developer/csharp_comparative.htm#20]
---
---
An 'assembly' is the equivalent of a 'package' in Java.
---
---
[book: source: Merriam Webster dictionary]
assembly = a company of persons collected together in one place usually
for some common purpose.
So here in this context this will become:
a collection of files collected together in one place usually for some
common purpose.
---
---
Thus you could say about the structure:
In Backus Naur form:
assembly = manifest files
files = file+
file = classes
classes = class+
---
In words:
An assembly is a manifest and a collection of files.
Where files is one or more file.
Where file is a collection of classes.
Where classes is one or more class.
And where exactly one of this classes contains a 'main()' method.
---
---
Internet: see also:
---
C#: Class: Friend: Can someone tell me what a friend class is in C#?
http://www.faqts.com/knowledge_base/view.phtml/aid/24737/fid/791
---
C# Course: Joe Grip
http://www.joegrip.com/csharp-course.html
---
C#: A Comparative Overview
http://genamics.com/developer/csharp_comparative.htm#20
----------------------------------------------------------------------