I have an app that targets .net 3.5 but since 3.5 is backwards compatible with earlier versions of the .net framework users can still run my app but with some problems. The errors dont cause it to crash, but an error report is generated and if the user clicks continue the app appears to continue without problems but doesnt perform the actions defined correctly for whatever event would be taking place.
With removing imports to 3.5 only namespaces and changing the compiler target framework to 2.0 plus changing .count to .length where appropriate in my code I can make my app work fully on 2.0 without any problems.
Problem is, with MS supporting installation of .net 3.5 in Windows XP I'd like to keep my application's target framework at 3.5 so I can take advantage of newer features. Because of the problems users get running my app when they've got older versions of .net installed I would like to create an if condition in the app's load event to retrieve the .net version if possible for the end user's system. If its lower than 3.5, I'll have the app promptly let the user know of potential problems.
So...
Code:
if (.netversion < 3.5) {
MessageBox.Show("Update please!");
}
What namespace/function do i use for .netversion?
EDIT: Apologies, its a lot easier than I thought:
Code:
if (System.Enviornment.Version < 3.5) {
MessageBox.Show("Update please!");
}