I'm pretty new to .NET and C#.
I recently took up the task of upgrading my application from .NET 4.0 to .NET 4.5 to keep up with other products in my team.
I would like to be able to run my application (which has several projects, some web projects based on ASP .NET and some standalone app projects (console application)) on .NET 4 and .NET 4.5.
After following instructions online regarding <supportedRuntime>
Element to upgrade from .NET 4.0 to .NET 4.5 by changing the target run-time I realized that the compilation
element's targetFramework
attribute is now 4.5
. I understand that this means the code will definitely work on .NET framework 4.5.
What if I have a set of nodes that are waiting for 4.5 upgrade which are still running .NET 4.0. I'm pretty sure that my changes would break the application.
So I did some research and after referring to some documentation online, I've removed the sku
attribute from the supportedRuntime
element in the *.config
files of the projects in the solution. Though the version
attribute of the supportedRuntime
element is still v4.0
(CLR version). I hope this make the application run on both .NET framework 4.0 and 4.5.
But I don't really know much about the compilation
element and its significance apart from what I read from ASP .NET configuration guidelines. Would leaving the targetFramework
make sure that my applications work on both .NET 4.0 and .NET 4.5?
How can I make sure that my changes are compatible with both .NET 4.0 and .NET 4.5?
[Why not leave it as .NET 4.0 till the nodes have their .NET frameworks upgraded?]
You might wonder why I can't keep it as .NET 4.0 for now. The aim is to upgrade to .NET 4.5. But the standalone script runs on a set of nodes that run on Windows Server 2003 that does not support .NET 4.5. I've got my system admin team to allocate another node with .NET 4.5 for this process alone. So for the time being I can't really completely upgrade my existing code. Until after I test my existing code on .NET 4.5 and configure deployment to those new nodes. Thanks to that comment from @hvd which lit a bulb in my confused brain. Now I know how to proceed.