Slot 01-Introduction to .NET Platform _ Visual Studio.NET
Slot 01-Introduction to .NET Platform _ Visual Studio.NET
NET Core
Platform and Visual Studio.NET
Objectives
◆ Overview .NET Framework Architecture
◆ Overview .NET Core and .NET
◆ Introduction to Cross-platform application with .NET
◆ Explain why .NET Core and C# Language is selected as develop
application?
◆ Explain meaning "dotnet CLI”
◆ Explain about NuGet package
◆ Demo create and run C# Console Application on Windows, Mac
and Linux using “dotnet CLI”
2/8/2021 2
Overview .NET Framework
What is the .NET Framework
.NET Framework 1.0
◆ Microsoft .NET Framework 1.0 was released Feb
13, 2002 is the original implementation of .NET .NET Framework 1.1
◆ Developed and run-on Windows platform only
.NET Framework 2.0
◆ Closed
◆ It supports ASP.NET Web Forms, WinForms, .NET Framework 3.0
WCF, Silverlight, WPF, LINQ, ADO.NET Entity
Framework, Parallel LINQ, Task Parallel Library, .NET Framework 3.5
etc
◆ The .NET Framework 4.8 version was released .NET Framework 4.0
2/8/2021 4
.NET Framework 4.5 Architecture
2/8/2021 5
The .NET Framework Architecture
◆ The two core components of the .NET Framework integral to any
application or service development are:
• Is a backbone of .NET Framework
• Performs various functions such as:
• Memory management, Code execution
Common • Error handling, Code safety verification
Language
Runtime (CLR) • Garbage collection(GC)
2/8/2021 6
Common Language Runtime(CLR)
◆ A common runtime for all .NET languages
▪ Common type system
▪ Common metadata
▪ Intermediate Language (IL) to native code compilers
▪ Memory allocation and garbage collection
▪ Code execution and security
◆ Over 15 languages supported today
▪ C#, VB, Jscript, Visual C++ from Microsoft
▪ Perl, Python, Smalltalk, Cobol, Haskell, Mercury, Eiffel, Oberon, Oz, Pascal,
APL, CAML, Scheme, etc.
2/8/2021 7
Common Language Runtime (CLR)
◆ Using the .NET Framework:
▪ The code of a program is compiled into
CIL (formerly called MSIL) and stored in
a file called assembly
▪ This assembly is then compiled by the
CLR to the native code at run-time
◆ In traditional Windows applications:
▪ Codes were directly compiled into the
executable native code of the operating
system
2/8/2021 8
Advantages of CLR
◆ Interoperation between managed code and unmanaged code (COM,
DLLs)
◆ Managed code environment
◆ Improved memory handling
◆ JIT (Just-In-Time) Compiler allows code to run in a protected
environment as managed code
◆ JIT allows the IL code to be hardware independent
◆ CLR also allows for enforcement of code access security
◆ Verification of type safety
◆ Access to Metadata (enhanced Type Information)
2/8/2021 9
Common Language Infrastructure
2/8/2021 10
Common Language Infrastructure
◆ Four components:
▪ Common Type System (CTS)
2/8/2021 11
Common Type System (CTS)
◆ The common type system defines how types are declared, used, and
managed in the common language runtime, and is also an important part of
the runtime's support for cross-language integration. The common type
system performs the following functions:
▪ Establishes a framework that helps enable cross-language integration, type safety,
and high-performance code execution
▪ Provides an object-oriented model that supports the complete implementation of
many programming languages
▪ Defines rules that languages must follow, which helps ensure that objects written in
different languages can interact with each other
▪ Provides a library that contains the primitive data types (such as Boolean, Byte,
Char, Int32, and UInt64) used in application development
2/8/2021 12
Common Type System (CTS)
◆ The common type system in .NET supports the following five categories
of types:
▪ Classes
▪ Structures
▪ Enumerations
▪ Interfaces
▪ Delegates
2/8/2021 13
CTS Data Types
2/8/2021 14
. The .NET Framework Architecture
◆ Common Language Specification (CLS)
▪ The CLS comprises a set of rules that any language that targets the CLI needs
to adhere to, to be able to interoperate with other CLS-compliant languages.
▪ CLS rules fall into the broader rules of the CTS and therefore it can be said
that the CLS is a subset of CTS.
▪ Language constructs that make it impossible to easily verify the type safety of
the code were excluded from the CLS so that all languages that work with the
CLS can produce verifiable code.
2/8/2021 15
The .NET Framework Architecture
2/8/2021 17
Cross-Platform Application
◆ A platform is a computer hardware and software combination on which a
program runs. A platform is a combination of both hardware resources: CPU
frequency, RAM size, HDD space, GPU capacity,…and also the software
platform being provided to install on such as Operating system; Third-party or
extended framework(.NET or JVM,..)
◆ Cross-platform support runs on multiple platforms. In a sense, it means that a
code can run on multiple frameworks, platforms, operating systems, and
machine architectures.
◆ A cross-platform programming language is one that can run on multiple
frameworks, operating systems, and machine architectures. Many factors
cause the language or tool to be able to run on multiple machines and
platforms.
2/8/2021 18
Overview .NET Core
What is the .NET Core?
◆ .It is a cross-platform, open-source framework that implements .NET
Standard.
◆ The .NET Core 5(.NET) version was released November 10, 2020.
2/8/2021 21
.NET 5 (.NET) = .NET Core
vNext
◆ Released on November 10, 2020 (Visual Studio 2019 and C# 9.0)
2/8/2021 22
What is the .NET Standard?
◆ .NET Standard is a specification that can be used across all .NET
implementations. It is used for developing library projects only. This
means if we are creating a library in .NET Standard we can use
those in .NET Framework and .NET Core.
2/8/2021 24
New features in .NET 5 (.NET)
◆ Java interoperability will be available on all platforms.
2/8/2021 25
Benefits of using .NET
◆2/8/2021
Modular: Ships as NuGet packages 26
Benefits of using .NET
◆ Host Agnostic:
▪ .NET Core on the server side is not dependent on IIS and, with
two lightweight servers: Kestrel and WebListener
2/8/2021 27
Benefits of using .NET
◆ Support for leveraging platform-specific capabilities, such as Windows
Forms and WPF(Windows Presentation Foundation) on Windows and
the native bindings to each native platform from Xamarin.
◆ High performance.
◆ Side-by-side installation.
◆ Visual Studio, Visual Studio for Mac, and Visual Studio Code integration.
2/8/2021 28
.NET components
◆ Language compilers: These turn source code written with languages
such as C#, F#, and Visual Basic into intermediate language (IL) code
stored in assemblies. NET language compilers for C# and Visual Basic,
also known as Roslyn
◆ Common Language Runtime (CoreCLR): This runtime loads assemblies,
compiles the IL code stored in them into native code instructions for
computer's CPU, and executes the code within an environment that
manages resources such as threads and memory
◆ Base Class Libraries (BCLs) of assemblies in NuGet packages (CoreFX):
These are prebuilt assemblies of types packaged and distributed using
NuGet for performing common tasks when building applications
2/8/2021 29
Why C# is selected as develop application?
◆ C# was developed by Anders Hejlsberg and his team during the
development of .NET
◆ C# is a modern, object-oriented, and type-safe programming language. C#
enables developers to build many types of secure and robust applications
that run in the .NET ecosystem. C# has its roots in the C family of
languages and will be immediately familiar to C, C++, Java, and JavaScript
programmers
◆ C# is designed for Common Language Infrastructure (CLI), which consists
of the executable code and runtime environment that allows use of various
high-level languages on different computer platforms and architectures
2/8/2021 30
Why C# is selected as develop application?
◆ The following reasons make C# a widely used professional language
▪ It is a modern, general-purpose programming language
▪ It is object oriented.
▪ It is component oriented.
▪ It is easy to learn.
▪ It is a structured language.
▪ It produces efficient programs.
▪ It can be compiled on a variety of computer platforms.
▪ It is a part of .Net
◆ More C# features :
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/
2/8/2021 31
Introduction to dotnet CLI
◆ The .NET command-line interface(CLI) is a cross-platform for developing,
building, running, and publishing .NET applications.
◆ More dotnet CLI :
https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet/
2/8/2021 32
Introduction to dotnet CLI
2/8/2021 33
Introduction to dotnet CLI
2/8/2021 34
Demo Create a C# Console App
using dotnet CLI
On Windows OS
◆ Install package: dotnet-sdk-5.0.102-win-x64.exe and open Command
Prompt dialog
1. Create Console App named HelloWorldApp with C# language
2/8/2021 36
2. Build HelloWorldApp application
2/8/2021 37
On macOS 10.14 "Mojave"
◆ Install package: dotnet-sdk-5.0.102-osx-x64.pkg and open Terminal dialog
2/8/2021 38
On Linux(Ubuntu 14.05) OS
◆ Install package: dotnet-sdk-5.0 and open Terminal dialog
1. Create Console App named HelloWorldApp with C# language
2/8/2021 39
Compilation Process .NET Application
2/8/2021 40
Compilation Process .NET Application
◆ The compiler used by the dotnet CLI tool converts .NET source
code(C#/VB/C++,..) into Intermediate Language (IL) code, and stores the IL
in an assembly (a DLL or EXE file).
▪ IL code statements are like assembly language instructions, but they are executed by
.NET Core's virtual machine, known as the CoreCLR.
◆ At runtime, the CoreCLR loads the IL code from the assembly, JIT compiles it
into native CPU instructions, and then it is executed by the CPU on your
machine.
◆ The benefit of this two-step compilation process is that Microsoft can create
CLRs for Linux and macOS as well as for Windows. The same IL code runs
everywhere because of the second compilation process that generates code
for the native operating system and CPU ...
2/8/2021 41
Common Intermediate Language (CIL)
◆ CIL is a platform-neutral intermediate language (formerly called Microsoft
Intermediate Language or MSIL) that represents the intermediate language
binary instruction set defined by the CLI. It is a stack-based object-oriented
assembly language that represents the code in byte-code format
2/8/2021 42
Introduction to Visual Studio.NET Read by
yourself
◆ Visual Studio is one of the most famous IDE’s has been using for the last few
years. Microsoft developed it. It is used to create a computer program, web
applications, and EXE files, etc. The first version of its kind was launched in
1997. And now the latest version available in the market is Visual Studio 2019.
2/8/2021 43
Introduction to Visual Studio.NET Read by
yourself
◆ New User Experienced Start Window: Check out the code, Open a
project, Open a folder and Create a new project
◆ Visual Studio Live Share: Live Share is a developer service in Visual
Studio 2019. This feature directly enables to share code context and
debugging process with your teammates and get live access within Visual
Studio itself like Google document services.
◆ Improved Refactoring: Refactoring in any IDE will highly helpful for
developers. In Visual Studio 2019 these refactorings will come up with new
advanced features, and these are used to organize your code in a
structured manner.
2/8/2021 44
Introduction to Visual Studio.NET
◆ Enhanced Search Experience
◆ Search Feature While in Debugging
◆ Visual Studio IntelliCode
◆ Code cleanup in One Click
◆ Integrated Code Reviews in Development
◆ Per Monitor Aware Rendering(PMA)
◆ New Delivery Model for SQL Server Data Tools
2/8/2021 45
Introduction to Nuget packages
◆ .NET is split into a set of packages, distributed using a Microsoft supported
package management technology named NuGet. Each of these packages
represents a single assembly of the same name.
▪For example, the System.Collections package contains the
System.Collections.dll assembly.
2/8/2021 46
Introduction to Nuget packages Read by
yourself
◆ Install and use a package for .NET project in Visual Studio
▪ Using NuGet Package Manager
▪ (For Windows:
https://docs.microsoft.com/en-us/nuget/quickstart/install-and-use-a-pack
age-in-visual-studio
)
▪ (For Mac:
https://docs.microsoft.com/en-us/nuget/quickstart/install-and-use-a-pack
age-in-visual-studio-mac
)
▪ Using the dotnet CLI
2/8/2021 47
Summary
◆ Concepts were introduced:
▪ Overview about .NET Core, .NET 5(.NET) and .NET Framework
▪ Overview .NET Framework and .NET 5(.NET) Architecture
▪ Overview new features of Visual Studio.NET
▪ Explain about Cross-platform application with .NET
▪ Why .NET Core and C# Language is selected as develop application?
▪ Explain and demo using “dotnet CLI” to create C# Console App
▪ Overview NuGet package
▪ Create and Run cross-platform Console application with C#
48