471,325 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

An Assembly can include several .exe files?

right?
Jan 1 '06 #1
5 4949
Nice,

No, it can't. It can include several modules, but not several EXE
files. After all, it's one file, which can be of type exe or DLL.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Nice" <Ni**@discussions.microsoft.com> wrote in message
news:4D**********************************@microsof t.com...
right?

Jan 1 '06 #2

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:O5**************@TK2MSFTNGP14.phx.gbl...
Nice,

No, it can't. It can include several modules, but not several EXE
files. After all, it's one file, which can be of type exe or DLL.

Hope this helps.


An assembly can contain many files. As far as I know, only one of them can
be of type .DLL or .EXE. And I'm not sure if it's required that there be
either an EXE or DLL: can any other type of file contain the assembly
manifest?
Jan 1 '06 #3
Mike,

An assembly can contain many modules. Ultimately though, an assembly is
ONE file, with ONE manifest.

A module is not an EXE or a DLL, it is a module, very different.

Big difference.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mike Schilling" <ms*************@hotmail.com> wrote in message
news:OM**************@TK2MSFTNGP09.phx.gbl...

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:O5**************@TK2MSFTNGP14.phx.gbl...
Nice,

No, it can't. It can include several modules, but not several EXE
files. After all, it's one file, which can be of type exe or DLL.

Hope this helps.


An assembly can contain many files. As far as I know, only one of them
can be of type .DLL or .EXE. And I'm not sure if it's required that there
be either an EXE or DLL: can any other type of file contain the assembly
manifest?

Jan 1 '06 #4

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:uQ**************@TK2MSFTNGP09.phx.gbl...
Mike,

An assembly can contain many modules. Ultimately though, an assembly
is ONE file, with ONE manifest.


No, that's not true. (Well, the one manifest part is true.)

See, for instance, http://www.dnzone.com/ShowDetail.asp?NewsId=698, which
says

What is an assembly?
* An Assembly is a logical unit of code
* One assembly can contain one or more files :

There is one *main* file in as assembly, the one that contains the assembly
manifest. But it can refer to an arbitrary number of other files, all of
which are part of the assembly. To see this, do the following:

Link some C# classes into a module. It doesn't really matter what's in
them.

Link the following class into an executable, adding in the module created in
the previous step: (The command line looks like
"csc /addmodule:Package.netmodule Hello.cs" )

using System;
using System.IO;
using System.Reflection;

class Hello {
public static void Main()
{
try {
Assembly assm = Assembly.GetAssembly(typeof(Hello));
FileStream[] files = assm.GetFiles();
Console.WriteLine("" + files.Length + " files in assembly");
foreach (FileStream f in files) {
Console.WriteLine(f.Name);
}
}
catch (Exception ex) {
Console.WriteLine(ex);
}
}
}

Run it. You'll see output like:

2 files in assembly
c:\csharp\Hello.exe
c:\csharp\package.netmodule

Now delete the file containing the module. Try to run the executable again,
and you'll see an error like:
System.IO.FileNotFoundException: File or assembly name Package.netmodule,
or one
of its dependencies, was not found.
File name: "Package.netmodule"
at System.Reflection.Assembly.nGetModules(Boolean loadIfNotFound,
Boolean getResourceModules)
at System.Reflection.Assembly.GetFiles(Boolean getResourceModules)
at System.Reflection.Assembly.GetFiles()
at Hello.Main()

The error being that one of the assembly's files is missing.

Jan 2 '06 #5

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:uQ**************@TK2MSFTNGP09.phx.gbl...
Mike,

An assembly can contain many modules. Ultimately though, an assembly
is ONE file, with ONE manifest.

A module is not an EXE or a DLL, it is a module, very different.

Big difference.

Nick,
Mike is right.

An assembly can span multiple modules AND multiple files, the file is just a
container for a module or a number of modules, the extention DLL or EXE is a
non issue here, you can take anything you like as an extention even for the
main assembly file.

Try this:
// m1.cs
using System;
class Tester
{
static void Main()
{
C c = new C();
c.Run();
}
}

// m2.cs
using System;
public class C
{
public void Run()
{
Console.WriteLine("Hello from m2");
}
}

//build m2 an create output module m2.dll
csc /t:module /out:m2.dll m2.cs
// add m2 to assembly
csc /addmodule:m2.dll m1.cs

Now you have a multifile assembly consisting of m1.exe and m2.dll. m1
contains the assembly manifest for m1 and m2.

Note that you can even do this :
csc /addmodule:m2.dll /out:m1.whatever m1.cs
and run it as m1.whatever

Willy.

Jan 2 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Madhav Desetty | last post: by
2 posts views Thread by Donal McWeeney | last post: by
2 posts views Thread by George Durzi | last post: by
10 posts views Thread by jojobar | last post: by
12 posts views Thread by Steven Berkovitz | last post: by
12 posts views Thread by TC | last post: by
10 posts views Thread by =?Utf-8?B?SmFtZXMgV29uZw==?= | last post: by
reply views Thread by rosydwin | last post: by

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.