Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

New C# 13 features does not work on Visual Studio 2022 Preview

Recently I installed Visual Studio 2022 Preview to check new features of C# 13. But when I open my previous projects and try to check out new features like new lock object, I get this error:

The type or namespace name ‘Lock’ does not exist in the namespace ‘System.Threading’ (are you missing an assembly reference?)

I tried reopening and copying exact examples from Microsoft documentation, but still I get error.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

If you open previous projects, their target framework are still on previous .NET you chose for those projects while creating them.

Go to: Project > ProjectProperties > Target framework
Choose the desired target framework.
Since you want to work with C# 13.0 features, you need to set to .NET 9.0 to be able to work with them.

Remember while making new projects, if you want to use new features of C# 13.0 and .NET 9, you should choose .NET 9.0 too.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading