Thread: Get .net framework version

  1. #1
    Registered User
    Join Date
    May 2009

    Get .net framework version

    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.

    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:

    if (System.Enviornment.Version < 3.5) {
    MessageBox.Show("Update please!");
    Last edited by kairozamorro; 05-18-2009 at 03:59 PM. Reason: Corrected errors in code

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem building Quake source
    By Silvercord in forum Game Programming
    Replies: 16
    Last Post: 07-11-2010, 09:13 AM
  2. code for calling the .NET framework version
    By Nyoud33 in forum C# Programming
    Replies: 1
    Last Post: 01-12-2009, 06:53 AM
  3. migrate from .Net 2.0 to .Net 3.0
    By George2 in forum C# Programming
    Replies: 3
    Last Post: 07-25-2007, 04:07 AM
  4. changing the version of .net used in visual c# 2005
    By Rune Hunter in forum C# Programming
    Replies: 2
    Last Post: 02-28-2005, 06:55 PM
  5. Visual J#
    By mfc2themax in forum A Brief History of
    Replies: 0
    Last Post: 10-08-2001, 02:41 PM