Tag Archives: .NET Framework

How to Select a .NET Framework

Motivation:

You need to select a .NET framework for your new project or for upgrading a legacy system.

However there are too many .NET framework branches so you are not sure which one is suitable with your need.

Guidelines:

You need to review the history of .NET framework and the differences among the various branches that include .NET Framework, ASP.NET Web Forms, ASP.NET MVC, .NET Core and .NET 6.

1. .NET Framework

The main purpose of .NET Framework is for building Windows Forms Applications.

  • .NET Framework 1.0 was released in 2002.
  • .NET Framework 2.0 was released in 2005.
  • .NET Framework 3.0 was released in 2006.
  • .NET Framework 3.5 was released in 2007.
  • .NET Framework 4.0 was released in 2010.
  • .NET Framework 4.5.2 was released in 2014.
  • .NET Framework 4.8.1 (the latest version) was released in 2022.
2. ASP.NET Web Forms

ASP.NET Web Forms was built on top of .NET Framework.

The main purpose of ASP.NET Web Forms is for building ASP.NET Web Forms Applications (multiple page web applications).

3. ASP.NET MVC

ASP.NET Web Forms does not follow MVC architecture pattern. Therefore MS built ASP.NET MVC.

ASP.NET MVC was built on top of .NET.

ASP.NET MVC is open-source software, apart from the ASP.NET Web Forms, which is proprietary.

The main purpose of ASP.NET MVC is for building ASP.NET MVC Applications (multiple page web applications based on MVC architecture pattern).

  • ASP.NET MVC 1.0 was released in 2009 (It was built on top of .NET Framework 3.5).
  • ASP.NET MVC 2.0 was released in 2010 (It was built on top of .NET Framework 4.0).
  • ASP.NET MVC 5 (the latest version) was released in 2022 (It was built on top of .NET Framework 4.8).
4. .NET Core

.NET Framework does not run on Linux or Unix and is proprietary. Therefore MS built .NET Core.

.NET Core runs on Windows, Linux and Unix, and is open-source software.

  • .NET Core 1.0 was released in 2016.
  • .NET Core 3.1 was released in 2019.
  • .NET Core then was renamed to just .NET in 2020 and .NET 5 was released in 2020. The .NET 4 name was not used to avoid name collision with .NET Framework.
  • .NET 8 (the latest LTS version) was released in 2023.

The main purpose of .NET Core or .NET is for building Windows Forms Applications, ASP.NET MVC Applications and Single Page Applications that run on Windows, Linux and Unix.

The ASP.NET Web Forms Application type was removed from .NET Core or .NET.

5. .NET 8

Currently (in 2024) MS supports 2 branches of .NET:

  • .NET Framework 4.8.1 (containing Windows Forms Applications, Web Forms Applications, and ASP.NET MVC Applications) and
  • .NET 8 (containing Windows Forms Applications, ASP.NET MVC Applications and Single Page Applications).

Both .NET Framework 4.8.1 and .NET 8 support building microservices.

6. ASP.NET
  • .NET is a developer platform made up of tools, programming languages, and libraries for building different types of applications.
  • ASP.NET is a .NET web framework. ASP.NET extends the .NET platform with tools and libraries specifically for building web apps. ASP.NET runs only on Windows.
  • ASP.NET Core is the cross-platform version of ASP.NET. ASP.NET Core runs on Windows, Linux, macOS, and Docker.
  • ASP.NET Core MVC is ASP.NET Core with UI components written in HTML, CSS, JavaScript and C#.
  • ASP.NET Core Razor Pages is ASP.NET Core with UI components written in HTML, CSS, JavaScript, Razor markup and C#.
  • ASP.NET Core Blazor is front-end web framework with code written in HTML, Razor markup and C#, and relies on a .NET runtime built with WebAssembly for client-server interactions.
7. Final thoughts

For a new system, you probably should use .NET 8 and ASP.NET Core.

For a legacy system, if you are using ASP.NET Web Forms then you may stick with .NET Framework 4.8.1. Otherwise you may upgrade your system to .NET 8 and ASP.NET Core.

 

 

How to Automate Cleaning Up a .NET Solution

Motivation:

You have a .NET solution with many projects.
You need to deliver the solution to a client very frequently.
You need to clean up all intermediate folders and files to reduce the package size and make the result look tidy.
You want to automate this process to reduce cleaning up time.

Solution:

  1. In Visual Studio, review Project Build Order… and a last project in the list.
  2. Right click the project and select Properties.
  3. Click on Build Events.
  4. Enter the following commands to the Post-build event command line text box:
    rd /s /q $(ProjectDir)obj
    cd $(TargetDir)
    del *.config
    del *.pdb
    del *.xml

    rd /s /q $(ProjectDir)obj: Remove the obj folder in the project directory.
    cd $(TargetDir): Move to the output directory.
    del *.config: Delete all the config files in the output directory.
    del *.pdb: Delete all the pdb files in the output directory.
    del *.xml: Delete all the xml files in the output directory.

    You can modify these commands or add new commands for your specific purpose.

  5. Save the project.
  6. Repeat the process for some other projects in the solution if necessary. Typically you only need to clean up intermediate folders and files for the some projects in the bottom of the build order list. You may use the Dependencies tab to change the build order for some projects.

Cleaning a folder manually:

In order to delete all the obj folders recursively you can

    1. Create DeleteObjFolders.bat file inside the same folder that contains your solution file (i.e. *.sln)
    2. Paste content below to the DeleteObjFolders.bat file:
    @echo off
    @echo Deleting all OBJ folders...
    for /d /r . %%d in (obj) do @if exist "%%d" rd /s/q "%%d"
    @echo OBJ folders successfully deleted :) Press any key to close the window.
    pause > nul

    3. Execute the DeleteObjFolders.bat file.

 

How to Remove Microsoft .NET Framework

Problem:

Some applications do not work with the latest Microsoft .NET Framework. You need to remove it and install an older version of Microsoft .NET Framework.

Solution:

1. Use below utility to remove the current Microsoft .NET Framework.

.NET Framework Cleanup Tool

2. Download an appropriate version of Microsoft .NET Framework using one of below links and install it.

3. Use below utility to detect the installed Microsoft .NET Framework versions.

.NET Detector