VS2022 makes class libraries with wrong .net framework version

I just tried making a C#9 class library with VS2022 and get the following error when adding it to my project:

When I make the class library with VS2019, this does not happen and it works as expected.


Something does not seem right with the core library when creating a new class library either, I find I have to delete the nuget package and reinstall it for new projects to build correctly.

This is on the latest visual studio extension version.

Can you please show step by step. We just try quickly and not see any problem.

if project was created from extension 2.1.801 or earlier then yes, it could be happened, even opened in 2.1.802 because template config still in 2.1.801.

Of you added a C# class library instead of TinyCLR class then the full .net gets pulled in and the whole project gets messed up

Yes, this project is some months old.

I just double checked and it was a tinyclr project.

You also have to ensure when adding the .cs file that TinyCLR is also selected when adding to a TinyCLR project. As Gus mentioned if you inadvertently add a regular C# class file it will gum up the whole works.

1 Like

Im still having this problem, and I am making 100% sure I am adding tinyclr classes to a tinyclr class library project.

That should be impossible but is it 2022?

Yeah its VS2022
Works fine from VS2019

I am not sure what exactly there because no project to take a look

But you can try to select the version of framework by select property of project. I guess the project was made on 4.8 then build on 4.5 pc?

We will take a look again.

I can’t change this property on the project, it is grayed out.

It’s not a huge deal, it’s easy enough to open VS19 for creating a class library. Adding classes and such work just fine from VS2022.