I know this question has been answered in other post but it dosent solves my problem:
Senario:
i have developed an application .net framework 3.5 sp1 using WPF
When i run the application by clicking the executable i wish to check if the required .net Version is installed or else give a message to the user….. i tried all solution available on the net….
but if the Run the application on a machine which does not have .net framework or has a framework version lower that 3.5 .. its shows the crash screen

My Code that i am currently using in App.Xaml.cs
//Check the registry entry for .NET Framework.
RegistryKey frameworkRegistryKey =
Registry.LocalMachine.OpenSubKey(DOT_NET_FRAMEWORK_KEY_PATH);
if (frameworkRegistryKey != null)
{
//Check for the installed versions.
string[] versionNames =
frameworkRegistryKey.GetSubKeyNames();
double framework =
Convert.ToDouble(
versionNames[versionNames.Length - 1].Remove(0, 1));
int servicePack = Convert.ToInt32(
frameworkRegistryKey.OpenSubKey(
versionNames[versionNames.Length - 1]).GetValue(
SERVICE_PACK, 0));
//Check if the version is 3.5 Service Pack 1 or later.
if ((framework < 3.5)
|| ((framework == 3.5) && (servicePack < 1)))
{
returnCode = ErrorCodesEnum.ERR_DOT_NET_FRAMEWORK;
}
}
I also doubt that if its possible as without the right libraries how will my application run
Any help or suggestions will be gr8
No matter what you do, if minimum required .NET version is not installed on the system you can’t detect it using a program targeting .NET since it won’t run at all! You’ll need to use a bootstrapper with your installer to detect the framework installation and install it as necessary.