Getting Stared with .Net Core 2.1

Getting Stared with .Net Core 2.1

28 May 2024
Beginner
16.3K Views
15 min read
Learn with an interactive course and practical hands-on labs

.NET Course

".NET" most common name in software development industry, typically famous for its rapid and fast development. .NET Microservices Training can help you to understand .NET for growing your career .NET is a software framework that used to create software applications, it is designed and developed by Microsoft to develop and run software on windows platform. It has strong set of class libraries with Common Language Runtime (CLR) to compile and execute code written in .NET, it supports lot of languages including VB, C#, F#. .NET has play a big role in software development industry, it has the changed the way we developed software in earlier days, changed views of developers, Now software development become more easy due to its modularized architecture and strong set of libraries

History

1st version of .NET framework that is 1.0 was introduced in 2002, where it was tested and installed on Windows XP operating system. Later on Microsoft has developed framework 1.1 in year 2003 and 2.0 in year 2005, Microsoft has also developed an IDE on which developer can write code using different .NET supported languages, this IDE is known as Microsoft Visual Studio, MS Visual studio is very powerful, popular and strong IDE with all set of libraries and controls, it is used overall for .Net programming till now. .NET framework 2.0 is among the most popular framework where lots of applications have developed, In nowadays also You can find many software that has developed with .NET 2.0 and still they are supporting on latest operating system (Windows 10), Later on Microsoft has made many changes in framework and the series is continued from 1.0 to 4.7.2 (released in April 2018), .NET framework has changed a lot over years it is now supporting Desktop based applications (WinForms), Web-based applications and windows universal platform (all windows platform tools from smartphone, tabs, hololens etc.) but still there are some limitations in .NET framework that it does not support cross-platform operating system like Linux and Mac (iOS).

Introduction to .NET Core

To overcome this limitation Microsoft has extend .NET framework capabilities and introduced .NET Core framework in Nov 2014. After getting your hands dirty on Dot Net Microservices Certification you will understand It is a free, open-source .NET framework that supports Linux and MacOS. It also contains CoreCLR and set of compiled libraries. .NET core 1.0 was released on June 2016 that supports web apps (Asp.Net Core), Command line apps and UWP Apps. .NET Core 2.0 was released in Aug 2017 with Visual studio 2017, Entity framework Core 2.0, Asp.NET Core 2.0. .NET Core 3.0 was announced in May 18 which supports Desktop apps (WinForms and WPF) and AI (Artificial intelligence) [.NET Core 3.0 is just announced but it will officially release in 2019]

Features of .NET Core

Yes, as it is the new generation .NET framework, it contains all features of .NET framework + its own new features, let’s go through them

  • Cross platform support : .NET Core is supporting development of apps that can be deployed beyond windows platform, we can deploy our apps on Linux or on MacOS

  • Containers and Dockers support : Containers and dockers are very famous in these days, they can be easily adaptable by cloud technologies, Don’t worry .NET Core has full support of these components

  • Performance Improvement

  • MVC and web API merged : Before .NET Core, Developer needs to use MVC and Web API separately to create REST services using JSON, but .NET Core does job more simpler and merged them in a single module

  • Seamless support to Microservices

  • Command line development possible on Windows, MacOS, Linux

  • It support adjacent .NET versions per applications

.NET Core 2.1 Architecture

According to above Image

CoreCLR

To run .NET programs we need .NET Runtime environment that is provided by CLR (Common language runtime), the same concept is applicable to .NETCore also; the runtime of .NETCore is called as CoreCLR, which is supported by System.Private.Corelib library. This library includes JIT (Just-In-Time) compiler, GC (Garbage collector), Some base .NET data types with some classes in it.

.NET Runtime adaption layer

It is nothing but a abstract layer between runtime and operating system., which interact between .NET runtime and operating system

Base Class Library

As name suggest it is the basic class library that includes classes like System.string, System.DateTime and more. And Base class library is the subset of FCL (Framework class library) that includes all class libraries required to run ASP.NET Core, ASP.NET webforms, AJAX, Windows app store, LINQ, WCF etc.

Windows store model and ASP.NET Core model

These models are nothing but supported class libraries that support UWP (Universal windows platform) and Web Apps respectively.

Advantages

  • Cross platform compatibility : Apps developed using .NET core is supported on Windows, Linux or MacOS environment

  • Open Source : It is open source and available on GitHub

  • New Features introduced with enhancement in performance

  • DVM (.NET Version manager) and DEE (.NET Execution environment) are the command line tools that are used to configure and execute .NET runtime on command line

  • Support to HTTP/2 (It is the new version HTTP protocol that is faster than HTTP/1, it uses binary data to transfer on web)

  • Seamless Support to 3rd party JavaScript toolkit and runner like Grunt and Gulp

  • Power of MVC and WebAPI at one place

Setting Up Machine

You need following things to cook your .NET Core code

Client OS : Windows 7.1 onwards (x64, x86)

Editor : Visual Studio 2017 (Version 15.7.0 or higher) For deployment you need Windows server 2008 SP1 or higher

Creating Your .NET Core Application

Let’s create sample application using .NET Core 2.1. There are two way you can create your first .NET core sample application

  • Using direct .NET Core cross platform development (From workloads)

  • Using File New Project Menu

    Checkout them one by one

  • Open Visual studio 2017

  • Select .NET Core cross platform development

    Here to note that VS 2017 (Version 15.7) has .NET Core 2.0 SDK installed and VS 2017 (Version 15.8) .NET Core 2.1 SDK and for .NET Core 2.2 preview 1 use VS 2017 (Version 15.9)

  • Go to Project => Properties and in Target framework choose .NET Core 2.1

    OR

  • Open Visual studio

  • Select File => New=> Project Select .Net Core (In left pane) and Console App (.NET Core) in .NET Core

  • When you click on ok button, Visual studio will open default template with inbuilt class. [Hello world sample] (Refer below image)

You just need to compile and run code (The code is as simple as a basic C#.NET program)

Summary

In this article we have seen .NET Core has introduced to overcome cross-platform compatibility issue of .NET framework. It comes with a lot of great features and advantages to create cutting-edge, modern web and windows apps (Compatible to Linux and MacOS). .NET Core bring MVC, WebAPI, Microservices under one roof. In next release of .NET Core [i.e. 3.0], it will support WinForms and WPF also. Finally, Rome was not built in a day and .NET Core is not a single cup of tea. Next article will cover more depth on .NET Core including ASP.NET Core, ASP.NET MVC Core, and migrations from legacy application to .NET Core.

Share Article
About Author
Prasad Kulkarni (Microsoft MVP and Sr. Technical leader)

He is Sr. Technical leader by profession and very passionate about Microsoft .NET technology. He likes to write articles on different .NET aspects and likes to help developers so that they can resolve their issues. He believes in "Earning Knowledge" is an endless entity.
Accept cookies & close this