[Mono-list] Confused!

Jonathan Pryor jonpryor@vt.edu
Tue, 28 Oct 2003 22:08:36 -0500


It's magic. :-)

CIL (.NET) executables use the "standard" PE (Portable Executable)
format that the rest of Windows uses.

To ensure that you can start a CIL program "normally" (for Windows
users), a trick is played.  The .EXE has an dependency on another
library (not a managed assembly, but a normal Windows DLL installed in
%WINDIR%\system32), and sets the program entry-point into a function
exported by this DLL (CorExeMain, or something).

The end result is that (again, on Windows) the OS loads the EXE, loads
all dependent libraries, which (indirectly) loads the .NET runtime, and
the .NET runtime takes over the process and starts JITing/executing the
CIL code.

In essence, the "portable" .EXE/.DLL format has some native X86 code to
ensure it works "right" on Windows.  Other platforms can (and do!)
easily ignore it.

Why's an MCS-generated program execute when Mono isn't installed? 
Because MCS generates programs with the same file header, so that they
can be executed under .NET.

The only way to keep from executing a program is to un-install both Mono
and .NET.

 - Jon

On Tue, 2003-10-28 at 17:50, Richard Thombs wrote:
> Well I thought of that, and although I still have it installed, it's
> not mentioned in any of the environment variables like PATH etc.
>  
> Are the executables built using Microsoft's CSC somehow aware of the
> path to Microsoft's mscorlib.dll?
>  
> R
>         -----Original Message-----
>         From: John BouAntoun [mailto:jbouantoun@rogen.com.au] 
>         Sent: Tuesday, October 28, 2003 2:36 PM
>         To: Richard Thombs; mono-list@lists.ximian.com
>         Subject: RE: [Mono-list] Confused!
>         
>         
>         Are you sure that you can uninstall the MS.Net framework after
>         it's been installed?
>          
>         Doesn't it become part of windows?
>                 -----Original Message-----
>                 From: Richard Thombs [mailto:mono@stony.org]
>                 Sent: Wednesday, 29 October 2003 9:27 AM
>                 To: mono-list@lists.ximian.com
>                 Subject: [Mono-list] Confused!
>                 
>                 
>                 I just built the mono and mcs trees from scratch under
>                 cygwin. Initially I was having all trouble getting
>                 some stuff to compile because I didn't have any
>                 corlib.dll whatsoever. I solved that by using the .NET
>                 SDK to compile and install it, so I should be happy,
>                 right?
>                  
>                 Well nearly - while trying to repeat the entire build
>                 process so that I can document it, I found that
>                 despite removing every corlib.dll I can find, things
>                 like 'mcs' are still able to execute. I'm confused
>                 because I was expecting to get a missing library
>                 error! I've even gone as far as rebooting so I can be
>                 sure Cygwin isn't caching the DLL in some weird way.
>                  
>                 Am I being stupid or what? Did I imagine the initial
>                 "Can't find corlib.dll" errors or what?
>