Lesson 1 - Overview of .NET •Microsoft .NET is a combination of significant new and enhanced technologies •The lessons are arranged in such a manner as to gradually bring COBOL programmers into these technology areas in a logical manner .NET in a Nutshell •Encompasses new trends in software development – distributed computing, componentization, enterprise services, Web integration of applications, language interoperability •Encompasses many standards – SOAP, WSDL, UDDI, HTTP, HTML, XML •Microsoft .NET languages – C#, VB.NET, C++, J# •Fujitsu .NET languages – COBOL and Fortran •Visual Studio .NET is the common IDE for all .NET languages •ADO.NET •Windows Forms •ASP.NET and Web Forms •Web Services •Smart Devices .NET in a Nutshell – Part 2 •Announced in July of 2000 •.NET is a new Applications Platform consisting of: –Development Tools and framework –Specialized .NET Enterprise Servers such as SQL Server, Biztalk Server, Commerce Server, Application Center Server , Host Integration Server, Internet Security Server, Acceleration Server –Web Services such as Passport and Hailstorm –Smart Devices Components and Topics •Common Language Specification (CLS) •Microsoft Intermediate Language (MSIL) •Metadata and Manifest •Assemblies (Executables) and the Global Assembly Cache (GAC) •Namespaces •Just in Time (JIT) compilers and the Verifier •Common Language Runtime (CLR) •Managed vs. Unmanaged Code and Platform Invocation Services •Framework base classes •Data and XML Classes •Windows Forms •Web Forms •Web Services •Visual Studio .NET
Common Language Specification (CLS) •Supports multiple language integration •Specifies a set of common data types (CTS) •Defines rules for external component accessibility •Takes full advantage of exceptions, inheritance, and polymorphism. •Provides for automatic garbage collection •All .NET compilers must adhere to the CLS and CTS Microsoft Intermediate Language (MSIL) •Abstract intermediate language – a concept common to many COBOL compilers •Similar to an Assembly Language with additional commands to handle objects •All .NET Compilers must produce MSIL (sometimes called “IL”). Microsoft Intermediate Language (MSIL) – COBOL Source The next slide shows a snippet of code from the MSIL produced by the NetCOBOL compiler for a HelloWorld example as shown below: IDENTIFICATION DIVISION. PROGRAM-ID. MAIN. ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. PROCEDURE DIVISION. DISPLAY "HELLO WORLD". END PROGRAM MAIN.
A snippet of code from the MSIL produced by the NetCOBOL compiler for a Hello World example:
.method public hidebysig static int32 Procedure() cil managed { .entrypoint // Code size 234 (0xea) .maxstack 8 .locals init (int32 V_0, class [Fujitsu.COBOL]Fujitsu.COBOL.Runtime.ProgramControl.DisplayInfo[] V_1, class [Fujitsu.COBOL]Fujitsu.COBOL.Runtime.ProgramControl.DisplayInfo[] V_2, valuetype [Fujitsu.COBOL]Fujitsu.COBOL.COBOLData V_3) .try { .try { IL_0000: ldsfld int32 MAIN::__CompInitialInfo IL_0005: brtrue.s IL_0017 IL_0007: ldc.i4.0 Metadata and Manifest •.NET Executables contain metadata – detailed descriptions of data types and interfaces •This includes descriptions of classes, methods, properties, fields, events, etc. •Metadata allows executables to be truly self-contained and self-describing •Metadata is kind of like a super type library •The use of Metadata removes the requirement to use the Windows registry •A vast improvement over COM •Aids in language interoperability •.NET assemblies also contain a Manifest which describes everything about the assembly such as files belonging to it, external references to other assemblies and classes, permission requests, and anything else required for component usage Application Domains •.NET Assemblies execute within an Application Domain •Similar to Windows Processes •Multiple Application Domains may run within a single Windows Process •Provides significant scalability •Managed code assemblies running under CLR provides reliability
Assemblies •.NET Executables are called “Assemblies” •Assemblies contain a Manifest, Metadata and MSIL •Assemblies may contain a single module or multiple modules •Assemblies may be Static, Dynamic, Private or Public (Shared) •Assemblies may be versioned allowing multiple versions of the same named assembly to be available on the same machine allowing side by side execution •Shared Assemblies must be registered in the Global Assembly Cache (GAC) at installation time •Shared Assemblies must be keyed •Assemblies may have unique security and permissions set Namespaces •Provides a way to group classes logically •Adds another level of scoping for classes •Allows organization of classes •Namespaces may be hierarchical using dots as separators Just in Time (JIT) Compilers and the Verifier •Translates MSIL into Machine Code •The Verifier first checks type safety at runtime •Multiple JIT’s available •Native Code produced is cached by default •Typically, only portions of an application that are referenced are JIT’ed. JIT may thus be incremental throughout the life of an application •.NET comes with Standard JIT, EconoJIT and PreJit •EconoJit targets small hardware platforms and does not cache code •PreJit may be used to pre-compile applications to native code and cache such at installation time (invokes Standard JIT) Common Language Runtime •Loads, manages and executes .NET executables (assemblies) •Activates .NET objects, security checks them, lays them out in memory, executes them and garbage collects them •Manages JIT of applications
Managed vs. Unmanaged Code and Platform Invocation Services •Managed Code is any executable produced by a .NET Compiler •Unmanaged Code is any executable code produced by a non-.NET compiler such as non-.NET versions for Fujitsu COBOL •.NET Compilers may optionally produce unmanaged code •.NET provides Platform Invocation Services to allow .NET applications (managed code) to call non-.NET applications and pass data to and from such •.NET Platform Invocation services are known as “PInvoke” Framework Base Classes •Important building blocks for .NET applications •Includes basic data types •System is the root of the .NET base class Namespace •A large number of these classes are provided. They include system object, collections, data, I/O, Web and Web Forms, Windows Forms, Network, and even Win32 Data and XML Classes •System.IO class provides basic file I/O streaming functionality •System.Data class provides ADO.NET relational database functionality •System.Data.OleDb allows for managed providers to be implemented •System.Data.SqlClient allows for managed providers using SQL to be implemented •System.XML class provides significant XML functionality Windows Forms •Kinder, gentler way to develop graphical user interface (GUI) Windows Applications •Visual Studio .NET provides graphical forms painter for all integrated .NET languages, including Fujitsu NetCOBOL •Code is automatically generated within the program source code being edited by the Forms painter •Developers may concentrate on writing event procedures for GUI applications, as opposed to being forced to write code to actually implement the GUI controls and related event handling •.NET Framework provides System.WinForms class for Windows Forms
Web Forms •Allows development of ASP.NET pages with graphical controls and event driven programming model •Visual Studio .NET provides graphical web forms painter for all integrated .NET languages, including Fujitsu NetCOBOL •ASP.NET pages containing program code to implement the desired controls are automatically generated by the Forms painter •Developers may concentrate on writing event procedures for ASP.NET applications, as opposed to being forced to write code to actually implement the GUI controls and related event handling •.NET Framework provides System.Web.UI class for Web Forms Web Services •Allows access to distributed application components via standard Web protocols such as HTTP and SMTP •Makes use of SOAP (Simple Object Access Protocol) •Opens up a whole new world of Web based callable software service components •Uses WSDL (Web Services Description Language) to discover and interface to remote Web Service components •Third Party Web Services already appearing such as Microsoft’s Passport •.NET Framework provides System.Web.Services framework class Visual Studio .NET •Visual Studio .NET is the common Integrated Development Environment (IDE) for all enabled languages •Provides a rich set of tools, including project management, edit, build and debug, forms painters, server explorer, etc. •Same editor and debugger are used across all enabled .NET languages •Substantial integrated Help system documents the .NET framework and languages