Question, what is the first thing you check before deploying to a production environment? If your answer was "What's the latest supported .Net version on the server?", then congrats!!, you are on track and you can stop reading now!!
But if it wasn't, then keep reading...
If your team doesn't have full control over the production servers you use
(which, in my experience, is 90% of the time), then you have probably seen
this issue before. Your code is x number of versions ahead of the latest .Net version
installed on the server... Bummer... Of course by the time you realize this,
it's already too late... your code is live and users of your app are already
getting a nice
500 Internal Server Error message...
So, how can you avoid this? Check the latest supported .Net version on the server and update the target framework version on your solution...