Changing .NET framework version

Contents

Changing .NET framework version#

After you updated .NET framework on your operating system, projects you previously created may not work with the following error message:

You must install or update .NET to run this application.

App: /home/u/projects/ind-prog-code/scratchpad/bin/Debug/net9.0/scratchpad
Architecture: x64
Framework: 'Microsoft.NETCore.App', version '9.0.0' (x64)
.NET location: /usr/share/dotnet

The following frameworks were found:
  10.0.0 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]
 ...

Solution#

First we update the .NET version we use.

  1. Open your project.

  2. In the solution explorer, right click your solution (not project). Solution is one level under the project.

  3. Right click Properties. Project properties should open up.

  4. In Application properties, on the right of the Target Framework, click ....

  5. Deselect the older version and select the new version, e.g., net10.0 instead of net9.0.

  6. Close Edit Target framework.

  7. Also update Language Version, i.e., select C# latest minor (default).

After this you should be able to compile and run your project, even some programming keywords will be red, because they are not recognized. For example InitializeComponent() will be red in an Avalonia-based project. To fix this, we have to invalidate caches of Rider:

  1. Click the sandwich menu on the top left.

  2. Click Invalidate Caches.

  3. Click Invalidate and Restart.

Now, all the functions should be correctly recognized.