I am confused as to what exactly .NET actually is. I am a Computer Science student who has done a lot of Win32 (WinAPI) programming in C++ & have a pretty good understanding of how Win32 functions interact with COM & the Windows Kernel itself.
But where does .NET fit into all this?
Sp开发者_开发问答ecifically, if Win32 is an API written in C, what is .NET? Is it an API written in C also? Does it only run on Windows OS like Win32?
Does .NET run on top of the Win32 API? For example a .NET function
showWindow()
(I made that up obviously) call Win32 functions behind the scenes to show the window or does it go directly to the Kernel to do this? Or is .NET like the Java Virtual Machine?Does .NET interact with the Windows Kernel directly (like Win32) & interact with COM objects? Does .NET run in a sandbox & not allow some access to certain OS areas?
I can code in different languages using the Win32 API such as c/c++, VB, Perl. What languages can I code in .NET?
This is what really stumps me. I hear about web applications written in .NET? What, how, wha? What language is it written in? Does .NET run on top of IE? Do .NET web applications work on Firefox or on Safari(MacOS)? Is a .NET web app like a java applet, do you get .NET drive bys too.
Some brief answers to keep you going:
Specifically, if Win32 is an API written in C, what is .NET? Is it an API written in C also?
.NET consists of multiple parts. One part is called the CLR. That part is written in C++, C++/CLI, and some assembly. This is responsable for Running the .NET appplications. The Just-In-Time (JIT) Compiler is an important part of this.
Then there are the included libraries. These are mostly written in C#, but some of them presumably have parts written in C++/CLI. You can actually get the source code for many of the included libraries.
Does it only run on Windows OS like win32?
Also no, there is a port that runs on Linux (called Mono), there is the version that runs on WIndows Phone 7, and then there is Silverlight which also runs on Macs....
Does .NET run ontop of the win32 API?
To a large degree, yes, although in some places it is starting to replace the regular WinAPI (it was certainly Microsoft's plan at one stage to try and .Net-ify most or all of the WinAPI). I wouldn't be writing drivers with it though, you will still use regular C/C++ interfacing to the Kernel API.
The libraries do make calls to many different portions of the win32 API. This is required to smoothly interoperate with other Windows Applications.
Does .NET interact with ... COM objects?
Yes it does, using COM interop.
Does .NET run in a sandbox & not allow some access to certain OS areas?
Some variants of the runtime can be sandboxed (Silverlight, WPF XBAP). .Net applications which possess the UnmanagedCode
permission can also call code written in unmanaged C++ with full unfettered access to the system (you still have to abide by little pesky things like file ACLs though).
I can code in different languages using the win32 API such as c/c++, VB, Perl. What languages can I code in .NET?
.Net is a runtime library with JIT compilation. There are many languages you can use that are built on top of the framework. The JIT compilation is also not mandatory - you can still compile your applications to target a specific CPU architecture.
I hear about web applications written in .NET? What, how, wha? What language is it written in? Does .NET run ontop of IE? Does .NET webapps work on Firefox or on Safari(MacOS)?
Those applications can be written in any .Net language, although practically most of them will be using C# and VB.Net. You must have heard of ASP? Well, ASP.NET (and its sister ASP.NET MVC) is the next generation - this runs on the server and renders out HTML + javascript like many other server side languages. You also have the option of running Silverlight on the client, it can run both in and out of the browser. Silverlight most definitely works in Firefox, Safari and Chrome.
- .NET is a MS brand for a CLI VM; there are CLI VMs for other platforms; mainly "mono"; however, even .NET is wider than just win32, since versions of .NET exist for XNA (xbox 360), mobile devices (CF), even smaller devices (MF), browsers (SL) and phones (WP7, etc). .NET is also sometimes used as the name of the library, and much of that is written in C#. In Windows 8 there is also WinRT which confuses things further.
- (see the above, too) a mix of both; it has interop (P/Invoke) for when it needs OS features, but can be self-supporting too.
- it is generally a VM, so yes it is a sandbox; note that some compilers exist (mono AOT) for compiling directly to native code, for example ARM for iOS devices (see: MonoTouch)
- CLI compilers compiles to IL; there are many CLI compilers (and runtimes, for dynamic languages). IL is generally JIT'd to native code as-needed, but can be done ahead-of-time (NGEN), or not at all (MF is an IL interpreter)
- the "web application" there is probably referring to the server part; this very site has a C#/.NET server implementation. There is also Silverlight and XBAP for in-browser client experience. Silverlight works on a number of browsers, as does moonlight (the mono version, for non-windows platforms).
There are several parts to what .NET is.
- The runtime. This is written in C (AFAIK) - it is what .NET application run on. Has a garbage collector. This is what interacts with the Windows Kernel.
- The BCL (Base Class Library) this is a set of .NET libraries. Some of these are wrappers over COM. Earlier versions had more COM wrappers than the later ones.
- The CL/IL (Common Lanaguage/Intermediate Language). This is a low level language (similar to Java bytecode). Most .NET languages compile to this and this is what the runtime executes.
Microsoft has made parts of .NET into a standard - parts of which have been implemented for Linux with the Mono project.
You can interact with COM using .NET using pInvoke (Platform Invoke). In this respect, it is not sandboxed. This means you can call any PE style executable using .NET. And of course there is a myriad of languages that compile to IL (called .NET languages) - the best known are C#, VB.NET and F#, but there are implementations of python (Iron Pyton), COBOL and many more.
As for web applications - there are several web frameworks (ASP.NET and ASP.NET\MVC are the Microsoft created ones) that run on the IIS web server. .NET does not run in a browser, not natively, but the server generates HTML that the browser uses. As with all other web applications, if developed that way, they can work on all browsers.
You can use .NET in the browser using plug-ins (Silverlight and MoonLight are the best known).
The .NET Framework contains a run-time engine (JIT/Native Compiler) and has a large collection of libraries written primarily in C#.
This allows languages developed using Common Language Infrastructure (CLI is an open specification) to sit upon the framework as the compilers for each individual language compile the code into MSIL (Microsoft Intermediate Language) which the .NET Runtime engine executes.
Currently, Novel are developing Mono which is a cross platform Runtime Engine for .NET CLI Languages, but again it's still quite early on, Most of the .NET 3.5 Specification is implemented.
As far as "web apps" go, Applications developed in ASP.NET are all server side and serve back HTML and javascript to browsers in an attempt to emulate some WinForm style actions.
But Silverlight, is a browser plug-in for non-IE browsers which contains a cut down version of the .NET Runtime engine and libraries, which in-turn executes applications written in a .NET CLI Language on the local computer.
simply you can think of it as a wrapper for the win32 API's "actually it is!" and also it is full framework that separate the programmer from the old API's and its problems
it has a run-time like java and it is capable of working in several platforms
and of course all if that is working above the windows API's
a simple article about dot net here http://www.codeproject.com/KB/dotnet/allaboutnet.aspx
精彩评论