Table of Contents

    Overview

    First, we need to know what .NET framework is. Let’s understand first it. .NET framework is a software framework which is developed by Microsoft and is a free and open-source software development platform.

    We are developed cross-platform web and mobile UI and services by the .NET framework. It includes developer tools, programming languages, and a large class library for buildup web and desktop applications that run on Microsoft windows. The first version of the .NET framework was 1.0 which was released in the year 2002.

    The .NET Framework includes four below components:

    1. Common Language Runtime (CLR)
    2. Framework Class Library (FCL),
    3. Core Languages (WinForms, ASP.NET, and ADO.NET), and;
    4. Other Modules (WCF, WPF, WF, Card Space, LINQ, Entity Framework, Parallel LINQ, Task Parallel Library, etc.)

    For a long time, when a Hire Microsoft .NET developer wants to transfer solutions other than the Windows platform, it generally involved another language (like java or C). Those implementations in Java or other cross-platform solutions didn't seem to run as smoothly in many cases. .NET framework is 18 years old, so it’s very difficult to rewrite the whole framework, so Microsoft start to scratch a new framework called .NET Core, which is cross-platform compatibility. It means one single source code for all platforms like Windows, Mac, Linux.

    Introduction

    .NET 5, the updated version of .NET Core 3.1 and .NET Framework 4.8, aims to develop cross-platform development for developers and bring new features. Merge the .NET framework and .net core framework into a single framework called.NET5 and the company choose a new name because they did not want users to confuse the 4.x version with the .net framework.

    .NET5 is important to release Microsoft in an open-source environment. With this release, we will have single .net runtime and framework which will have uniform behavior across platforms like Windows, Mac, Linux, etc.

    .NET 5 combine .net framework, .net core, Xamarin, mono, so now this all combine into a single framework, and developers can take advantage of this and develop windows, iOS, and android application with this single .NET 5 framework.

    .NET 5 will support command line, better performance, and smaller SDK size and single BCL (base class library) across all.

    What’s new in .NET 5?

    1. Unified Platform:

    The first thing we must know is .NET 5 which is a single platform for developing applications that run on all platforms and devices like windows, Mac, Linux etc. The most important thing is unifying MONO and xamarin.

    .NET 5 gives a set of API for different types of runtime applications, which is identified by TFM(Target Framework Moniker).TFM is one type of token that we set in the .NET project for a specific target framework, using this application run on any runtime implementation supporting .NET 5.

    2. Added New features in C#:

    The second thing we must know about .NET 5 is that added new features in C# which is called C# 9. There are many features in C# 9 as follows:

    2.1 Top-level statements:

    As part of .NET 5 new features is “Top-Level statements”. This removed to add program class with the main method in console application also didn’t require declaring namespace initially and write statements directly at the top-level of a file.

    Look at the following program:



    In this program, we have declared namespace, program class and main () method and this Program we write in only one top-level statement as below. In this case, the compiler generates a class and Main method entry point for the application.

    Recommendation: Integrating Hibernate with Asp.Net Application

     


    Top-level statements are implicitly in the global namespace and executed in the order they appear in the file. Top-level statements can only be used in one source file in your application. The compiler generates an error if you use them in more than one file.

    2.2 Record types:

    Record types are other great features of C# 9 that enable the whole object to be immutable and make it act like a value: Records.

    The record type is one type of reference type object which gives data encapsulation functionality.

    Records are by default immutable reference types. Property values cannot be changed after initialization. If we want to change properties values, then need to create another object instance using WITH keyword.

    Records type cannot be inherited of class or class cannot be inherited records type. Records can inherit from other records. Record types are a complier features and complier generates a class based on template.

    Every record type gets an equal’s implementations. Records work like struct means value type comparison, means value can be compared with value-based approach. Constructors and deconstructors are allowed in Records.

    2.3 .NET MAUI, the Universal UI:

    The third things we have to know about .NET 5 bring to build cross-platform UI(User Interface).Using .NET Multi-platform App UI (.NET MAUI) build native desktop and mobile apps with a single code base and integrate Blazor apps into .NET MAUI using webview.NET MAUI is an open-source cross-platform framework.

    MAUI is an evolution of Xamarin. Forms which extended from Mobile to Desktop application. Using MAUI we share the same UI layouts and designs and also the same business logic, fonts, and images, code to all platforms, which consumes time to design and reduce complexity in all platforms. Developers can write both cross-platform and platform code within one project means one project targeting multiple platforms and devices.

    Using MAUI, developer can access to sensors, like accelerometer, compass, and gyroscope on devices and check the device network connectivity state and detect changes, gives the device information on which app is run.

    This feature is still in under develop and will be released with .NET6

    2.4 Single-File Applications:

    The fourth things we must know about .NET 5 is to support single-file applications, which means applications published and build both in one single file also bundled all dependencies are into one file.

    When the app is run, the Single-File Applications approach gives the facility to load all bundled dependencies directly from that single file into memory. Now, Developers do not need to publish/deploy applications, only do publish or deploy application. Unlike .NET 3.1, this approach does not allow only binary packages.

    In .NET 5, single-file apps are primarily focused on Linux. They can be either framework-dependent or self-contained. Framework-dependent single-file apps can be very small, by relying on globally installed .NET runtime.

    Commands to produce single-file apps:

    Framework-dependent single-file app:
    dotnet publish –r linux-x-64 –self-contained false/p: PublishSingleFile=true

    self-contained single-file app with assembly trimming and ready to run enabled :
    dotnet publish –r linux-x-64 –self-contained true/p: PublishSingleFile=true /p: PublishTrimmed=true /p: PublishReadToRun=true

    Configure publish with a project file:

    <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net5.0</TargetFramework>
    <!-- Enable single file -->
    <PublishSingleFile>true</PublishSingleFile>
    <!-- Determine self-contained or framework-dependent -->
    <SelfContained>true</SelfContained>
    <!-- The OS and CPU type you are targeting -->
    <RuntimeIdentifier>linux-x64</RuntimeIdentifier>
    </PropertyGroup>
    </Project>

    Publish as a single File:
    We can see setting to use while creating a build for the app.so now select framework-dependent as deployment mode and target runtime as win-x64.

    2.5 Not Supported Technologies:

    The fifth thing we must know about .NET 5 is that not supported technologies means removing a few features supported in .NET Framework. Let’s talk about that removed feature.

    Asp.net Web Forms: Asp.net web forms will not be coming in .net 5 for build web UI.However,we have few alternatives to build web UI, if we want to build traditional web applications, use razor pages and if we want to use single –page applications, use Blazor, Angular or react.

    WCF (Windows Communication Foundation): The traditional communication framework for window is WCF which going to be deprecated. This news is shocking for developers that have to use service-oriented applications. We know the main concept of .Net 5 is a cross-platform. Microsoft recommending to use gRPC which is modern and open-source framework that run any enviourment.

    WWF (Windows Workflow Foundation): In .Net5 also not include WWF.As of now not comes any technology as a replacement for WWF.However, we use CoreWF which is open-source.

    DIFFRENCE BETWEEN .NET CORE 3.1 AND .NET 5

    .NET 5 is the successor to .NET core 3.1 and it is also .NET core 5.0, but renamed and removes “Core” Word. Things which is working in 3.1 which is continue to work in .NET 5.0, unless some intentional breakages between 3.1 and 5.0.

    .Net 5 includes below new features as compared to .NET Core 3.1:

    C# Updates: .Net 5 comes with new Features of C# with version 9.C# 9 includes features like Records value-type, Relational Pattern matching also including logical patterns with new keyword like and, or and not, top-level statement, function pointers.

    F# Updates: Net 5 comes with new Features of F# with version 5.F# 5 includes features like interpolated strings like C# and JavaScript. In addition, also set string interpolation with typed interpolation in that gives type for each formatter specifier.

    Single file app: In .Net core 3.1, when users run single-file app, first extracts all files to directory before running application. Net5 improves this functionality by directly running the code without extract files from the app.

    App Trimming: App trimming tool is introduced in .NET core which find unused assemblies and remove at the time of deployment.NET 5 comes with one step forward; not only remove unused assemblies but also removed unused code from assemblies by open that assemblies and remove types and members which is unused.

    System.Text.Json new features: In .NET 5 also added new namespace that provides extension methods for httpclient to perform serialization and deserialization using System.Text.Json with system.net.http.json.

    Windows ARM64 and ARM64 intrinsic: .Net core 3.1 introduces features called hardware intrinsic which gives access to send instruction that modern hardware support. Developer access this instruction using set of API under namespace System.Runtime.Intrinsics and System.Runtime.Intrinsics.X86 for x86/x64 architecture. In.NET 5 includes 384 other APIs under System.Runtime.Intrinsics. ARM.

    How to create .Net 5 Application

    Follow the below instruction to create .Net 5 application:

    • Create a .NET 5.0 Application with Visual Studio 2019
    • Open Visual Studio 2019
    • Click on “Create a new project”.
    • Choose “ASP.NET Core Web Application”

    Configure your new project

    Project Name: “DotNet5App”
    Click on the “Create” button.



    Choose .NET Core Version from Drop Down list


    Settings for our .NET 5 Web Application

    - Framework Version “ASP.NET Core 5.0
    - Application type: “Web Application”.
    - Enable Razor runtime compilation: Leave it unchecked
    - Then click on the “Create” button to create the project.

    The following is the screenshot of Visual Studio for a newly created Application:

    Run the Applications

    The project has been created successfully targeting .NET Core 5.0 now we run the application.

    SUMMARY

    Now, we have an idea of how .NET 5 will impact our existing .NET project and give new opportunities and offers, and the future of .NET 5 is exciting and very interesting. .NET 5 will become simpler while having more expansive and wider utility and capability with new features.

    About Author

    Manektech Team

    Milan Shah

    Chief Technical Officer

    Milan Shah is Chief Technical Officer at ManekTech, having 18+ years experience in .Net department and technical expertise with increasing leadership responsibility. Having an experience of business processes of various Domains like, Online ticket booking Industry, Law-Firm Industry and Transport & Logistics.

    Subscribe to Our Newsletter!

    Join us to stay updated with our latest blog updates, marketing tips, service tips, trends, news and announcements!

    OUR OFFICES


    ManekTech's Global Presence

    USA

    4100 NW Loop 410, Suite 200, San Antonio, Texas, USA 78229

    UK

    7 Artisan Place Harrow, HA3 5DS

    India

    4th Floor, Timber Point, Prahaladnagar Road, Ahmedabad, Gujarat - 380015

    Germany

    Franz-Joseph-Strasse, 11,Munich, 80801, Germany

    South Africa

    The Business Centre No 1. Bridgeway Road, Bridgeway Precint, Century City, Cape Town, South Africa, 7446

    PREV
    NEXT