Overview of the Microsoft .NET Framework
So far in this course, we have concentrated on one part of .NET, the Foundation Class Libraries. However, there’s more to .NET than the FCL. This lecture will tell you about other parts of .NET.
The Web has changed computing, and will change it more. In 1992 it seemed like a dream that you could connect to a computer in Sweden, click on a link and be connected to a computer in Japan. Now it seems normal.
Today it seems like a dream that you could use a program on your computer and it would call on other programs running on computers in Sweden and Japan, performing tasks for you. Of course, to some extent that is now achieved through a Web browser, using server-side programming. For example, if I want to know the cheapest source of two tons of 16-gauge copper wire, I might be able to find it.
This kind of thing is called “business to business” Web services (B2B). Since I’ve been giving this lecture for several years now, I have inadvertently stumbled upon an unscientific way of documenting the growth of B2B services:
-
In fall 2004 I could find a supplier in the United Kingdom and one in East Orange, New Jersey
-
In fall 2005 I couldn’t do any better with Google, at least not in five minutes.
-
In fall 2006 I could find several sellers of small quantities of wire for use in jewelry.
-
In fall 2007 things have developed considerably. Now, my problem is the opposite: there are so many suppliers of wire that I don’t know where to go. It seems that I need to know what I want to do with this wire, because there are different kinds. Do I want network wire, or aircraft wire, or electrical wire (in which case, civilian or military specs?), or what? There are Google ads from wire suppliers at the side of my search page clamoring for my attention, too.
The existence and ubiquity (if you need it there’s a dictionary at www.m-w.com) of bad guys in the world makes it difficult for people to allow other people to run programs on their computer. We need technical means to allow programs to run while ensuring that they can’t do damage. Moreover, the different computers in the world run different operating systems and have different underlying hardware, so it’s difficult to write programs on one computer that will run on many other computers.
Java offers one approach to these problems; .NET offers another. One could say that .NET is Microsoft’s answer to Java. The basic plan in both cases involves “byte code”. This is a kind of “universal assembly language”. It is a language intermediate between a high-level language and machine code for a particular machine. It is not meant to be written by humans, but produced by compilers. But it still needs one last translation stage to produce machine code. That last translation takes place at run-time.
Traditionally code was either compiled or interpreted. (I am assuming you know the difference.) Java and .NET use “just-in-time compilation” (JIT). That means that the byte code is used at run time to produce machine code, which should then execute at the same speed as if the program had been compiled. (Interpreted code often runs an order of magnitude slower.)
But the JIT compiler produces machine code specific for the target machine, so the byte-code file can run on any machine that has a JIT compiler.
There is another advantage to the byte-code approach—you can start with different source languages and produce compatible byte-code. So you could produce some components of your program in Visual Basic, some in C++, etc., and they should work together.
Both Java and .NET also offer features to “manage” the code in two important respects: they provide garbage collection for memory management, and security features to ensure that a program written by someone else (whom you may not trust very much) is safe to run on your computer.
In the case of .NET, this byte-code language is called Microsoft Intermediate Language (MSIL). The system that runs MSIL code (by using just-in-time compilation) is called the Common Language Runtime (CLR). It’s called that because it doesn’t matter by that time what language was used to produce the MSIL.
To aid in producing code that can be managed as described above, Microsoft developed the C# programming language, which is quite a bit like Java. It seems that the original plan was to use Java for that purpose, but for technical and legal reasons, that didn’t work out.
Microsoft also wrote the Framework Class Library (FCL) that provides thousands of classes and methods that make it possible to write .NET programs.
That still doesn’t quite complete the picture, because we haven’t provided a way for programs to call other programs over the Internet. For that we need a protocol for passing function calls and data over a network. Microsoft’s answer to this need is called SOAP: Simple Object Access Protocol. This protocol specifies how to formulate such data in XML (Extended Hypertext Markup Language) and send it over the web via the HTTP protocol that is already used for web pages.
Review of the parts of .NET and various acronyms:
CLR Common Language Runtime. The system that runs bytecodes, by compiling it “just in time” to executable code.
FCL Framework Class Library. A collection of classes to use in writing .NET programs. The CLR and the FCL are the two main components of the .NET framework.
MSIL Microsoft Intermediate Language. The bytecode produced by .NET compilers.
C# Programming language similar to Java used to produce CLR code (but other languages can also be used to produce CLR code)
HTML Hypertext Markup Language—used for web pages.
XML Extended (hypertext) markup language; XML “document type definitions” can be used to specify how to encode certain kinds of data in HTML.
SOAP Simplified Object Access Protocol. Enables programs to call each other over the Internet by passing data in XML form.
JIT Just In Time. A JIT compiler is needed on the target machine to convert CLR code to machine language at run time.
Web Service. (For some reason no acronym is used! Are we slipping, people? Why did we miss the chance to use WS?) This is a program meant to be used over the Internet by other programs. Example: Google provides a web service so that your program can access Google’s search facilities. That’s the way the Google toolbar (that you can add to your browser) works.
An Example of XML
For those with no prior knowledge of XML, let’s make the matter a little more concrete (I took this example from an article by Charles Wiltgen)
Charles
Wiltgen
This might be used by a web service that would return an author when sent an ISBN number (an ISBN number is a unique number assigned to a book). Future Vision
These technologies are designed to underpin a world in which some people (or companies, more likely) provide web services that are used (“consumed”) by other people (or companies). As first examples, a company might have internal web services for sales data or billing. Microsoft has an internal web service for travel reimbursement.
Business to business web services should provide a lucrative market. There is, Microsoft hopes, a potential to change the way companies conduct business with their customers and with their suppliers, making every aspect of the economy more efficient. Some of you students may be smart enough to figure out how to ride this wave to riches.
The Framework Class Library (FCL)
You have been using the FCL all semester so far. One should understand, however, that FCL is not just a “wrapper” of the Win32 API, as its predecessor MFC was. The FCL produces MSIL code and these programs will, in theory, run on any platform that supports .NET, which includes Linux and FreeBSD. (However, I haven’t tried this—it may be true only in theory, and it’s almost certainly not true for the GUI parts of the FCL—you can’t write a Windows program like those we’ve been writing so far and then run them on Linux.)
Visual Studio offers a single environment in which one can mix components built in different languages. One can, for example, implement a component in Visual Basic that defines a class X, and then implement another component in C# that defines a class Y derived from X. Before .NET, one could make DLLs or ActiveX controls, but the CLR offers a closer integration of different languages, and is simpler to use.
Summary
Here’s Jeff Richter’s list of features of .NET, from his book Applied Microsoft .NET Programming:
-
consistent programming model. (Replaces DLLS and COM)
-
simplified programming model (Goodbye to IDL and the registry)
-
Run once, run always (Goodbye to “DLL Hell”). [Yes, but this implies keeping many versions of the FCL on your machine. Nevertheless, this happens more or less automatically and they don’t interfere with each other, and hard disk space is cheap.]
-
Simplified deployment [Goodbye to the registry for installation and uninstallation]
-
Wide platform reach [You can run on any machine that can run CLR]
-
Programming language integration
-
Simplified code re-use (a market in components)
-
garbage collection
-
type-safe verification
-
rich debugging support
-
consistent method failure paradigm (exception throwing)
-
code access security
-
interoperability with pre-existing code
Building Applications with FCL and Visual Studio
We can build the following types of applications:
-
Windows Forms. Windows applications such as we’ve built so far.
-
Web Forms. Essentially these are Active Server Pages. This is the subject of a course in Server Side Web Programming, and will not be covered in this course.
-
XML Web Services. This is one of the main points of .NET.
-
Console applications. Applications without a graphical user interface.
-
Windows services. Not covered in this course.
-
Components. These modules define classes that expose methods for use in applications of the above types.
Share with your friends: |