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.
Open your project.
In the solution explorer, right click your solution (not project). Solution is one level under the project.
Right click
Properties. Project properties should open up.In
Applicationproperties, on the right of theTarget Framework, click....Deselect the older version and select the new version, e.g.,
net10.0instead ofnet9.0.Close
Edit Target framework.Also update
Language Version, i.e., selectC# 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:
Click the sandwich menu on the top left.
Click
Invalidate Caches.Click
Invalidate and Restart.
Now, all the functions should be correctly recognized.