Chapter 1. C# is a programming language – Designed to generate codes that targeted to use with.NET framework – Language based on object-oriented & component.

Slides:



Advertisements
Similar presentations
Introduction to .NET Framework
Advertisements

Tahir Nawaz Introduction to.NET Framework. .NET – What Is It? Software platform Language neutral In other words:.NET is not a language (Runtime and a.
Using.NET Platform Note: Most of the material of these slides have been taken & extended from Nakov’s excellent overview for.NET framework, MSDN and wikipedia.
History of.Net Introduced by Microsoft Earlier technology was VC++ and VB VC++ comes with so many library and VB was so easy to use and not flexible to.
.NET Framework Overview Pingping Ma Nov 16 th, 2006.
.NET Technology.
Web Development Using ASP.NET CA – 240 Kashif Jalal Welcome to week – 1.1 of…
Kashif Jalal CA-240 (072) Web Development Using ASP.NET CA – 240 Kashif Jalal Welcome to week – 2 of…
ISYS 512 Business Application Design and Development with.Net David Chao.
Introducing the Common Language Runtime for.NET. The Common Language Runtime The Common Language Runtime (CLR) The Common Language Runtime (CLR) –Execution.
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
Introducing the Common Language Runtime. The Common Language Runtime The Common Language Runtime (CLR) The Common Language Runtime (CLR) –Execution engine.
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
Session-02. Objective In this session you will learn : What is Class Loader ? What is Byte Code Verifier? JIT & JAVA API Features of Java Java Environment.
Intro to dot Net Dr. John Abraham UTPA – Fall 09 CSCI 3327.
Microsoft Visual Basic 2012 CHAPTER ONE Introduction to Visual Basic 2012 Programming.
Microsoft Visual Basic 2005 CHAPTER 1 Introduction to Visual Basic 2005 Programming.
INTRODUCTION TO WEB DATABASE PROGRAMMING
A Free sample background from © 2001 By Default!Slide 1.NET Overview BY: Pinkesh Desai.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
Lecture Roger Sutton CO530 Automation Tools 5: Class Libraries and Assemblies 1.
Visual Basic: An Object Oriented Approach 12 – Creating and using ActiveX objects.
Introduction to .Net Framework
Introduction to ASP.NET. Prehistory of ASP.NET Original Internet – text based WWW – static graphical content  HTML (client-side) Need for interactive.
ASP.NET INTRODUCTION INTO وزارة التربية و التعليم العالي كلية العلوم و التكنولوجيا قسم علوم الحاسوب و تكنولوجيا المعلومات اعداد الاستاذ: عبد الله محمد.
ISYS 512 Business Application Design and Development with.Net David Chao.
ASP.NET The.NET Framework. The.NET Framework is Microsoft’s distributed run-time environment for creating, deploying, and using applications over the.
1 8/29/05CS360 Windows Programming Professor Shereen Khoja.
.NET Overview. 2 Objectives Introduce.NET –overview –languages –libraries –development and execution model Examine simple C# program.
Session 1 - Introduction and Data Access Layer
Meir Botner David Ben-David. Project Goal Build a messenger that allows a customer to communicate with a service provider for a fee.
11 Getting Started with C# Chapter Objectives You will be able to: 1. Say in general terms how C# differs from C. 2. Create, compile, and run a.
.NET Framework & C#.
Introduction to.NET Framework. .NET – What Is It? Software platform Language neutral In other words:.NET is not a language (Runtime and a library for.
C# And.NET Architecture. C# is a relatively new programming language, and is significant in two respects:  It is specifically designed and targeted for.
Microsoft Visual Basic 2005: Reloaded Second Edition
 Internet providing backbone for applications  Use of several web sites and devices to provide one complete solution  Software as services  Quick software.
Understanding Code Compilation and Deployment Lesson 4.
Lesley Bross, August 29, 2010 ArcGIS 10 add-in glossary.
UNIVERSITI TENAGA NASIONAL “Generates Professionals” CHAPTER 4 : Part 2 INTRODUCTION TO SOFTWARE DEVELOPMENT: PROGRAMMING & LANGUAGES.
CIS 375—Web App Dev II Microsoft’s.NET. 2 Introduction to.NET Steve Ballmer (January 2000): Steve Ballmer "Delivering an Internet-based platform of Next.
Introduction .NET Framework
C# Overview and Features. Content I.History of C# II.Architecture III.How to install IV.Features V.Code Sample VI.Microsoft.NET Platform VII.Why use C#
Lecture 1 Programming in C# Introducing C# Writing a C# Program.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
Managed C++. Objectives Overview to Visual C++.NET Concepts and architecture Developing with Managed Extensions for C++ Use cases Managed C++, Visual.
.NET Framework Danish Sami UG Lead.NetFoundry
The Web Architecture and ASP.NET. Slide 2 Review of the Web (1) It began with HTTP and HTML, which delivers static Web pages to browsers which would render.
tom perkins1 XML Web Services -.NET FRAMEWORK – Part 1 CHAPTER 1.1 – 1.3.
Introducing ASP.NET 2.0. Internet Technologies WWW Architecture Web Server Client Server Request Response Network HTTP TCP/IP PC/Mac/Unix + Browser (IE,
Module 4 Part 2 Introduction To Software Development : Programming & Languages Introduction To Software Development : Programming & Languages.
ASP.NET in Definition: 1.ASP.NET is a web application framework developed and marketed by Microsoft to allow programmers to build dynamic web sites,
Key Components of.NET Framework  Common Language Runtime  CLR at Design time  CLR at Runtime  Class Library  Assemblies  Namespaces  ASP.NET  Applications.
PRIOR TO WEB SERVICES THE OTHER TECHNOLOGIES ARE:.
ASP.NET (Active Server Page) SNU OOPSLA Lab. October 2005.
Object Oriented Software Development 4. C# data types, objects and references.
C# and.NET. .NET Architecture  Compiling and running code that targets.NET  Advantages of Microsoft Intermediate Language (MSIL)  Value and Reference.
July 22, 2001Introduction to.NET1 Introduction to.NET Framework Gholamali Semsarzadeh July 2001.
The Execution System1. 2 Introduction Managed code and managed data qualify code or data that executes in cooperation with the execution engine The execution.
Text Introduction to.NET Framework. CONFIDENTIAL Agenda .NET Training – Purpose  What is.NET?  Why.NET?  Advantages  Architecture  Components: CLR,
Microsoft Visual Basic 2015 CHAPTER ONE Introduction to Visual Basic 2015 Programming.
A S P. Outline  The introduction of ASP  Why we choose ASP  How ASP works  Basic syntax rule of ASP  ASP’S object model  Limitations of ASP  Summary.
A Detailed Introduction To Visual Studio.NET CRB Tech ReviewsCRB Tech Reviews introduces you to the world of Visual.
Introducing the Microsoft® .NET Framework
Introduction to .NET framework
Introduction to Visual Basic 2008 Programming
Introduction to .NET Framework Ch2 – Deitel’s Book
.NET and .NET Core 2. .NET Runtimes Pan Wuming 2017.
Web Development Using ASP .NET
Presentation transcript:

Chapter 1

C# is a programming language – Designed to generate codes that targeted to use with.NET framework – Language based on object-oriented & component based technology.NET is a framework – Runtime environment – Includes collection of classes and services to develop s/w for web services and other applications – Exists as a layer between.NET applications and underlying operating system.

OLE Technology COM Technology.NET Technology Interprocess Communication Intermodule Communication Intersite Communication Early 1980’s 1995 Late 1990’s.NET framework ASP.NET (Web Services) Windows forms (User Interface) Framework Base Classes CLR

Advantages of.NET: – Object Oriented Programming – Good design – Language Independence – Dynamic web page – Efficient data access – Code sharing – Improved security – Zero-impact installation – Support web services – Visual studio 2008 – C#

C# is specifically designed and targeted for use with Microsoft’s.NET Framework The Relationship of C# to. NET

CLR – Central to the.NET framework runtime execution environment – Known as the Common Language Runtime (CLR) or the.NET runtime – It also support cross language interoperability Common Language Runtime Common Type System Intermediate Language (IL) Execution Support Functions Security Garbage Collection Class Loader Memory Layout – Code running under the control of CLR is managed code – Unmanaged code: code that can't directly hosted by.NET environment – Before executed by CLR, source code needs to be compiled

Compilation occurs in two steps in.NET – Compilation of source code to IL(MSIL or CIL). – Compilation of IL to platform - specific code by the CLR IL is like bytecode in java (based on numeric codes rather than text), which can be very quickly translated into native machine code Advantage : – platform independence – performance improvement – language interoperability

C# Source Code Compiler IL and Metadata EXE Code Class Loader Verifier Test Linker Metadata Engine Other Native Language Basic Class Library (for type safety) CLR activities for executing a program The C# compiler generate managed code. The managed code generated by C# is IL code The IL code is then converted to native machine code by the JIT Compiler

JIT Compiler Native Machine Code Runtime manager Output

Platform Independence – By compiling to IL, obtain platform independence for.NET, same as compiling to Java byte code which gives Java platform independence. – The platform independence of.NET is only theoretical – At present, a complete implementation of.NET is available only for Windows

Performance Improvement: – IL is always Just - in - Time compiled, whereas Java byte code was often interpreted – Instead of compiling the entire application in one go JIT compiler simply compiles each portion of code as it is called (just in time) – When code has been compiled once, the resultant native executable is stored until the application exits, so it does not need to be recompiled the next time that portion of code is run – This process is more efficient than compiling the entire application code at the start – Final compilation takes at runtime, so JIT compiler will do optimization according to what processor type the program will run on – Optimize the code by taking advantages of features offered by particular processor

Language Interoperability – IL enables platform independent, language interoperability – The compiled IL code can be interoperable with code that has been compiled to IL from other language – Languages that are inter operable with. NET are: C# Visual Basic 2008 Visual C

Features of IL – Object orientation and use of interfaces – Strong distinction between value and reference types – Strong data typing – Error handling using exceptions – Use of attributes

Object Orientation & Interfaces – A class written in one language can inherit from a class written in another language. – The class can contain an instance of another class, no matter what the languages of the two classes are. – An object can directly call methods against another object written in another language. – Objects can be passed around between methods.

Distinct b/w values & reference types – IL provides a number of predefined primitive data types. – IL makes a strong distinction between value and reference types. Value types are those for which a variable directly stores its data Reference types are those for which a variable simply stores the address at which the corresponding data can be found. – Instances of reference types are always stored in an area of memory known as the managed heap – Instance of value types are normally stored on the stack

Strong data typing – All variables are clearly marked as being of a particular, specific data type – Pointers are permitted only in marked blocks of code in C# – Strong Data Typing may improve the performance in services such as Language interoperability Garbage collection Security Application domains

Importance of strong data typing – If a class is to derive from or contains instances of other classes, it needs to know about all the data types used by the other classes – Absence of any such information become the real barrier to inheritance and interoperability across languages. – Eg: VB 2008’s Integer to C# int This can be achieved if only if the compiler knows how to map Visual Basic 2008 ’ s Integer type to some known type that is defined in C#

Common Type System This data type problem is solved in.NET using the Common Type System (CTS) The CTS defines the predefined data types that are available in IL, so that all languages that target the.NET Framework will produce compiled code that is ultimately based on these types – For the previous example, Visual Basic 2008 ’ s Integer is actually a 32 - bit signed integer, which maps exactly to the IL type known as Int32. – the C# compiler is aware of this type, there is no problem.

Common Language Specification The Common Language Specification (CLS) works with the CTS to ensure language interoperability The CLS is a set of minimum standards that all compilers targeting.NET must support. Subset of CTS CLS works in two ways – individual compilers do not have to be powerful enough to support the full features of.NET – it provides a guarantee that, if you restrict your classes to exposing only CLS - compliant features, then code written in any other compliant language can use your classes.

Memory management in.NET Two previous techniques used on the Windows platform for de-allocating memory are : – Make the application code do it all manually. – Make objects maintain reference counts Leads to memory leakage problem or object will be never removed problem The.NET runtime relies on the garbage collector The purpose of this program is to clean up memory Garbage Collection

All dynamically requested memory is allocated on the heap When.NET detects that the managed heap is becoming full, it calls the garbage collector The garbage collector runs through variables currently in scope in the code, examining references to objects stored on the heap to identify which ones are accessible from the code Any objects that are not referred to be no longer accessible from the code and can therefore be removed.

.NET offer code - based security Windows offers only role - based security Role - based security – based on the identity of the account under which the process is running Code - based security – based on what the code actually does and on how much the code is trusted The CLR is able to inspect code before running it, to determine required security permissions. Security

This is to ease the overhead involved when running applications that need to be isolated from each other but that also need to be able to communicate with each other In pre -.NET days, isolating code has been through processes. Windows isolates processes from each other through address spaces. Here one process can not access the memory allocated to another process  this may provide security but some performance loss is there. Application Domains

Often, a number of processes will actually be working together, and therefore need to communicate with each other In Application domain one process is divided into a number of application domains. If different executables are running in the same process space, then they are clearly able to easily share data  but CLR makes sure that this does not happen in practice by inspecting the code for each running application to ensure that the code cannot stray outside of its own data areas. If a running application does need to communicate or share data with other applications running in different application domains, it must do so by calling on.NET ’ s remoting services.

C#, handles exceptions using try{}, catch{}, and finally{} blocks of code. The exception architecture ensures that when an error condition occurs, execution can immediately jump to the exception handler routine It also pass an object containing precise details of the exception condition to an exception handling routine This object also give message for the user and details of exactly where in the code the exception was detected. Error Handling with Exceptions

An attribute provided extra information concerning some item in the program that could be used by the compiler Define own custom attributes in the source code These user - defined attributes will be placed with the metadata for the corresponding data types or methods Use of Attributes

An assembly is the logical unit that contains compiled code targeted at the.NET Framework (IL + Assembly) An assembly is completely self - describing and is a logical rather than a physical unit, which means that it can be stored across more than one file If an assembly is stored in more than one file, there will be one main file that contains the entry point and describes the other files in the assembly. Same assembly structure is used for both executable code and library code The only real difference is that an executable assembly contains a main program entry point, whereas a library assembly does not. Assemblies

An important characteristic of assemblies is that they contain metadata that describes the types and methods defined in the corresponding code An assembly, however, also contains assembly metadata that describes the assembly itself. This assembly metadata, contained in an area known as the manifest (communication between assemblies) Assemblies can be viewed by typing ildasm command Assemblies come in two types: – private – shared

Private Assemblies They normally distributed with software and are intended to be used only with that software The system guarantees that private assemblies will not be used by other software because an application may load only private assemblies that are located in the same folder that the main executable is loaded in, or in a subfolder of it. Because a private assembly is entirely self - contained, simply place the appropriate file(s) in the appropriate folder in the file system. This process is known as zero impact (xcopy) installation. Advantage Because of this there is no risk There are also no problems with name collisions.

Shared Assemblies Shared assemblies are intended to be common libraries that any other application can use Because of this shared concept precautions need to be taken against the following risks: – Name collisions – The risk of an assembly being overwritten by a different version of the same assembly Solution – placing shared assemblies in a special directory subtree in the file system, known as the global assembly cache (GAC)

Because assemblies store metadata, including details of all the types and members of these types that are defined in the assembly, it is possible to access this metadata programmatically This technique, known as reflection Versioning : – In.NET, able to run both version of s/w simultaneously – But, COM model contain dll hell problem Reflection

The.NET base classes are a massive collection of managed code classes that allow to do almost any of the tasks that were previously available through the Windows API. The.NET base classes are easy to use. NET Framework Classes

The areas covered by the.NET 3.5 base classes include: – Windows GUI support – Web Forms – Data access – Directory access – File system and registry access – Networking and Web browsing – NET attributes and reflection – Access to aspects of the Windows OS – COM interoperability

Using namespace.NET helps to avoid name clashes between classes A namespace is a logical grouping of data types The names of all data types within a namespace are automatically prefixed with the name of the namespace Most of the general - purpose.NET base classes are in a namespace called System. The base class Array is in this namespace, so its full name is System.Array. If a namespace is not explicitly supplied, the type will be added to a nameless global namespace. Namespaces

Console applications – text - only applications that run in a DOS window The different types of applications that you can write in C# are: – ASP. NET Applications – Windows Forms – Windows Presentation Foundation (WPF) – Windows Controls – Windows Services – Windows Communication Foundation Creating. NET Applications Using C#

Active Server Pages (ASP) is a Microsoft technology for creating Web pages with dynamic content An ASP page is basically an HTML file with embedded chunks of server - side VBScript or JavaScript. When a client browser requests an ASP page, the Web server delivers the HTML portions of the page, by processing the server - side scripts These scripts query a database for data and mark up that data in HTML. Creating ASP. NET Applications

Limitation of ASP – ASP pages sometimes render slowly because the server - side code is interpreted instead of compiled. – ASP files can be difficult to maintain because they are unstructured; the server-side ASP code and plain HTML are all jumbled up together. – ASP sometimes makes development difficult because there is little support for error handling and type - checking. ASP.NET is a complete revision of ASP that fixes many of its problems. Also program ASP.NET with C#!

ASP.NET pages are structured You can create ASP.NET in Visual Studio 2008 ASP.NET allows you to isolate the server-side functionality of a page to a class, compile that class into a DLL, and place that DLL into a directory below the HTML portion. Increased performance Features of ASP. NET

Web Forms Web forms are to make Web page construction easier They allow to build ASP.NET pages graphically Web Server Controls They are XML tags in the ASP.NET namespace that the Web browser dynamically transforms into HTML and client-side script when a page is requested

XML Web Services HTML pages account for most of the traffic on the World Wide Web An XML Web service is an easy way for a computer to expose information to other computers on the Web in the form of XML. An XML Web service on.NET is an ASP.NET page that returns XML instead of HTML to requesting clients.

A Windows Form is the.NET answer to a Visual Basic 6 Form To design a graphical window interface, just drag controls from a toolbox onto a Windows Form To determine the window’s behaviour, write event-handling routines for the form’s controls. Windows Form projects are supported by both Visual Basic 2008 and C# Creating Windows Forms

WPF makes use of XAML in building applications XAML stands for Extensible Application Markup Language. To run any WPF application, need to make sure that the.NET Framework 3.0 or 3.5 is installed on the client machine XAML is the XML declaration that is used to create a form that represents all the visual aspects and behaviours of the WPF application. Using the Windows Presentation Foundation ( WPF )

Web Forms use Web server controls, and Windows Forms use Windows Controls. A Windows Control is a lot like an ActiveX control. After a Windows Control is implemented, it compiles to a DLL that must be installed on the client’s machine. Windows Control creation involves deriving from a particular class, System.Windows.Forms.Control Windows Controls

A Windows Service is a program designed to run in the background in Windows NT/2000/XP/2003/Vista Services are useful when you want a program to be running continuously and ready to respond to events without having been explicitly started by the user Example is the World Wide Web Service on Web servers, which listens for Web requests from clients. It is very easy to write services in C#..NET Framework base classes are available in the System.ServiceProcess namespace Windows Services

How you move data and services from one point to another using Microsoft-based technologies – There are a lot of choices such as ASP.NET Web services,.NET Remoting, Enterprise Services, and MSMQ for starters. What technology should you use? because each technology is better used in a particular situation. Microsoft brought all of these technologies together, and with the release of the.NET Framework 3.0 as well as in the.NET Framework 3.5 Now we have a single way to move data — the Windows Communication Foundation (WCF) WCF provides with the ability to build the service one time and then expose this service in a multitude of ways Windows Communication Foundation ( WCF )

C# requires the presence of the.NET runtime, installing a C# application is likely to mean also installing the.NET When combined with ADO.NET, C# has the ability to access quickly and generically data stores such as SQL Server and Oracle databases. The returned datasets can easily be manipulated using the ADO.NET object model or LINQ, and automatically render as XML for transport across an office intranet. ASP.NET pages coded in C# constitute an excellent medium for user interfaces. The Role of C# in the. NET Enterprise Architecture