.NET and output file extension
Why Visual Studio compiles an application to an executable if it's in the MSIL f开发者_JAVA百科ormat? Shouldn't it be like java that compiles the code to a .class file?
a .NET "executable" is really a tiny _un_managed stub executable that creates an AppDomain, instantiates your startup .NET object and calls into it.
a .NET dll would be the equivalent of a java .class
Edit: -----
Jb Evain points out in comments that .NET dlls also contain an unmanaged stub.
The stub just jumps to the appropriate entrypoint in mscoree.dll
that does the actual work. CorExeMain
for exe's and CorDllMain
for dll's.
Because .exe means something to the OS - Windows doesn't have to register another executable type to run. .EXE files "just work" from the Run menu, the command line, and the shell.
But probably more importantly, because people have come to expect the behavior of a .exe file. I mean you've used .EXE files as the main executable file format on MS systems for the better part of 30 years now. If they compiled executable .net apps to, say, a ".CLR" extension, not everyone would know what to make of it, and that could have slowed the adoption of .Net, especially in the early days...
精彩评论