Using .NET 4.5 with Visual Studio 2022
By default Visual Studio 2022 will not install legacy .NET Frameworks and support .NET Framework 4x solutions and why should it honestly? But it can...here's how...
If you’re like me then you like using the newest tools. I love code completion, I love improved UI’s and added features (ones that make sense). However, if you’re also like me it’s not uncommon to come across technical debt that needs to be addressed.
Technical debt comes in many forms; it can come in infrastructure, syntax, frameworks, dependencies, architecture which impacts scalability, etc. However, sometimes debt comes in the form of a customer request on an old solution that nobody really wants to invest to make current — hey if it runs, why address the out-of-support framework right? Non-technical customers will more often than not disregard such debt and focus on features…from their perspective it’s completely understandable.
Visual Studio 2022 is pretty amazing, but it will not support .NET Framework 4.5 out of the box, even with ‘optional components’ (and rightfully so) but if you have the target frameworks — it can!
Problem: you open visual studio that has a project targeting an older .NET Framework, and you don’t want to install Visual Studio 2019…because…why would you? (I’ll discuss multiple IDE versions installed in parallel in another post, I promise, but let’s stay on topic). You’ll like come across an error like this:
You’ll immediately be tempted to use the continue button and download the targeted framework — and you’ll be greeted with this…
So…how we get around this? Visual Studio 2022 will happily support your solutions if you have the proper frameworks for it to do so, we just need to make it aware of the frameworks and ensure that we have them, so here’s what to do…
Download Microsoft.NETFramework.ReferenceAssemblies.net45 from nuget.org
Open the package as zip
Copy the files from build\.NETFramework\v4.5\ to C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5
Once you do this, you’ll need to restart Visual Studio, upon reload it will be aware of the added framework and your solution loading will no longer complain. Fore more information regarding .NET 4.5 with Visual Studio 2022 use this link: Building a project that target .NET Framework 4.5 in Visual Studio 2022
On the other hand (and contradictory to this post) you could always use the Visual Studio Installer and Install Visual Studio 2019 with it’s optional components and you’ll be able to manage your project that way also…but now you’re running an older IDE and potentially multiple versions of the same IDE (more common than you think with Visual Studio).
Happy coding!


