.NET applications not portable ?

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

Hi,

I've seen the following being explained about .NET applications in a C#
Microsoft Course :

"An assembly executable (exe) contains a small amount of unmanaged code,
known as the stub, which is used to load the .NET CLR and start execution of
the application. The reason this is unmanaged code is because the OS loader
in W2K and in previous Windows OS's doesn't recognize .NET applications and
because the runtime has not yet been loaded.
The stub is not present in assemblies that are not applications."

Does this mean then that my assembly executables (compiled on W2K) are not
able to run on Linux (using e.g. Mono) or on another OS that supports .NET,
since that portion of unmanaged stub (win32-code) will not be able to run ?

Thnx
Chris
 
Chris said:
I've seen the following being explained about .NET applications in a C#
Microsoft Course :

"An assembly executable (exe) contains a small amount of unmanaged code,
known as the stub, which is used to load the .NET CLR and start execution of
the application. The reason this is unmanaged code is because the OS loader
in W2K and in previous Windows OS's doesn't recognize .NET applications and
because the runtime has not yet been loaded.
The stub is not present in assemblies that are not applications."

Does this mean then that my assembly executables (compiled on W2K) are not
able to run on Linux (using e.g. Mono) or on another OS that supports .NET,
since that portion of unmanaged stub (win32-code) will not be able to run ?

No, you will be able to run them, but you may need to explicitly say to
load the CLR, eg saying:

mono foo.exe
 
Hi Jon,

executing : mono foo.exe

does it mean then that the unmanaged stub part of file 'foo.exe' (that
contains win32 code if compiled on Win) will not be used then ?

thnx
Chris
 
Chris said:
executing : mono foo.exe

does it mean then that the unmanaged stub part of file 'foo.exe' (that
contains win32 code if compiled on Win) will not be used then ?

Indeed.

Basically the stub part just tells it which CLR to load, and the
"mono" bit does that already.
 
Matt Davey said:
I believe, but could be wrong, that the PE header just has a bit set to say
its for .NET
http://www.codeproject.com/dotnet/insidedontnet.asp gives a little detail

http://www.smidgeonsoft.com/ has an interesting PE header utility

It's not just a bit being set. From the link above:

<quote>
The following section to the above is also a bit interesting. There we
have said that there is link to another module mscoree.dll. That is the
core of common language runtime. It also specifies the entry point to
the mscoree.dll, which allows the module to be attached to the current
process. Here it=3Fs shown as 0 _CorExeMain.
</quote>

That's what gets .NET loaded, basically.
 
Back
Top