chap 1 presentation

Upload: parameshwar6

Post on 09-Jan-2016

227 views

Category:

Documents


0 download

DESCRIPTION

c#

TRANSCRIPT

Before .NET

Before .NETWindows Programming in the Late 1990sIn the late 1990s, Windows programming using the Microsoft platform had fractured into a number of branches. Most programmers were using Visual Basic, C, or C++. Some C and C++ programmers were using the raw Win32 API, but most were using Microsoft Foundation Classes (MFC). Others had moved to the Component Object Model (COM). All these technologies had their own problems. The raw Win32 API was not object-oriented, and using it required a lot more work than MFC. MFC was object-oriented but was inconsistent and getting old. COM, although conceptually simple, was complex in its actual coding and required lots of ugly, inelegant plumbing. Another shortcoming of all these programming technologies was that they were aimed primarily at developing code for the desktop rather than the Internet. At the time, programming for the Web was an afterthought and seemed very different from coding for the desktop. Goals for the Next-Generation Platform ServicesList of The Goals:

Enter Microsoft .NET

In 2002, Microsoft released the first version of the .NET Framework, which promised to address the old problems and meet the goals for the next-generation systems. The .NET Framework is a much more consistent and object-oriented environment than either the MFC or COM programming technologies Some of its features include the following: Multiple platforms: The system runs on a broad range of computers, from servers and desktop machines to PDAs and cell phones. Industry standards: The system uses industry-standard communication protocols, such as XML, HTTP, SOAP, JSON, and WSDL. Security: The system can provide a much safer execution environment, even in the presence of code obtained Components of the .NET Framework

The execution environment is called the Common Language Runtime (CLR). The CLR manages program execution at run time, including the following: Memory management and garbage collection Code safety verification Code execution, thread management, and exception handling The programming tools include everything you need for coding and debugging, including the following: The Visual Studio integrated development environment (IDE) .NET-compliant compilers (e.g., C#, Visual Basic .NET, F#, IronRuby, and managed C++) Debuggers Web development server-side technologies, such as ASP.NET and WCF The Base Class Library (BCL) is a large class library used by the .NET Framework and available for you to use in your programs as well. Components of the .NET Framework cont.

Interoperability

The .NET Framework was designed for interoperability between different .NET languages, the operating system or Win32 DLLs, and COM. The .NET language interoperability allows software modules written using different .NET languages to interact seamlessly. A program written in one .NET language can use and even inherit from a class written in another .NET language, as long as certain rules are followed. Because of its ability to easily integrate modules produced in different programming languages, the .NET Framework is sometimes described as language-agnostic. The .NET Framework provides a feature called platform invoke (P/Invoke), which allows code written for .NET to call and use code not written for .NET. It can use raw C functions imported from standard Win32 DLLs, such as the Windows APIs. The .NET Framework also allows interoperability with COM. .NET Framework software components can call COM components, and COM components can call .NET components as if they were COM components themselves.

Simplified Deployment

Deploying programs written for the .NET Framework can be much easier than it was before, for the following reasons: The fact that .NET programs dont need to be registered with the registry means that in the simplest case, a program just needs to be copied to the target machine and its ready to run. .NET offers a feature called side-by-side execution, which allows different versions of a DLL to exist on the same machine. This means that every executable can have access to the version of the DLL for which it was built. Type Safety

The CLR checks and ensures the type safety of parameters and other data objectseven between components written in different programming languages. The Base Class Library

The .NET Framework supplies an extensive base class library, called, not surprisingly, the Base Class Library (BCL). (Its also sometimes called the Framework Class Library [FCL]). General base classes: Classes that provide you with an extremely powerful set of tools for a wide range of programming tasks, such as file manipulation, string manipulation, security, and encryption Collection classes: Classes that implement lists, dictionaries, hash tables, and bit arrays Threading and synchronization classes: Classes for building multithreaded programs XML classes: Classes for creating, reading, and manipulating XML documents Compiling to the Common Intermediate Language

An assembly is either an executable or a DLL. The code in an assembly isnt native machine code but an intermediate language called the Common Intermediate Language (CIL). An assembly, among other things, contains the following items: The programs CIL Metadata about the types used in the program Metadata about references to other assemblies Compilation Output is assembly

Compiling to Native Code and Execution

The programs CIL isnt compiled to native machine code until its called to run. At run time, the CLR performs the following steps, as shown in Figure 1-4: It checks the assemblys security characteristics. It allocates space in memory. It sends the assemblys executable code to the just-in-time (JIT) compiler, which compiles portions of it to native code.

Managed code: Code written for the .NET Framework is called managed code and needs the CLR. Unmanaged code: Code that doesnt run under the control of the CLR, such as Win32 C and C++ DLLs, is called unmanaged code. Summary

CLR

CLI

The Common Language Infrastructure (CLI) is a set of standards that ties all the components of the .NET Framework into a cohesive, consistent system. It lays out the concepts and architecture of the system and specifies the rules and conventions to which all the software must adhere. Component of CLIThe Common Type System

The CTS defines the characteristics of the types that must be used in managed code. Some important aspects of the CTS are the following:

The CTS defines a rich set of intrinsic types, with fixed, specific characteristics for each type. The types provided by a .NET-compliant programming language generally map to some specific subset of this defined set of intrinsic types. One of the most important characteristics of the CTS is that all types are derived from a common base classcalled object. Using the CTS ensures that the system types and types defined by the user can be used by any .NET-compliant language. The Common Language Specification The CLS specifies the rules, properties, and behaviors of a .NET-compliant programming language. The topics include data types, class construction, and parameter passing. C# History

2005Simple Program in C#