none
Detect .NET framework on different machine RRS feed

  • Question

  • Hi everybody,

    Is it possible to detect if .NET framework is installed on a machine different than the one you're running your .NET application on?

    Background info:

    I'm creating a setup and deployment program which needs to install .NET assemblies into multiple SQL Server databases (SQL CLR). These databases are not necessarily on the same server as the one you're executing the installer on, they might be on linked servers as well. The .NET assemblies are .NET 3.5 and the databases might be 2005 or 2008. In either case, I must be certain that .NET 3.5 is installed on those servers for the assemblies to work. Does anybody know of a way to check this?

    Regards, Stefan

    Friday, May 7, 2010 11:32 AM

Answers

  • I think this code here:

    http://blogs.msdn.com/astebner/pages/9763379.aspx 

    is basically registry reading to detect FW versions, so remote registry APIs should work.


    Phil Wilson
    • Marked as answer by Stefan_A Monday, May 10, 2010 7:21 AM
    Friday, May 7, 2010 6:07 PM
  • You can look via remote to your other machine and check the registry for .NET-Framework versions.

    Regards

     

    martinwy

    • Marked as answer by Stefan_A Monday, May 10, 2010 7:21 AM
    Saturday, May 8, 2010 1:33 PM
  • Hey guys,

    Indeed a remote registry check solves the issue! I'll post the code below so that others can use it also if they wish:

    /// <summary>Checks whether the .NET Framework 3.5 is installed.</summary>
    /// <param name="machineName">The machine to search on.</param>
    /// <remarks>Detection method as explained on the following page: <see cref="http://msdn.microsoft.com/library/cc160716.aspx"/></remarks>
    public static bool IsNetFrameWork35Installed(string machineName)
    {
    	RegistryKey HKLM = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, machineName);
    
    	RegistryKey framework35 = HKLM.OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5");
    
    	if (framework35 == null)
    		return false;
    
    	int keyValue = (int)framework35.GetValue("Install");
    
    	return keyValue == 1;
    }

    Thanks a lot for helping !

    Kind regards, Stefan

    • Marked as answer by YiChun Chen Tuesday, May 11, 2010 7:44 AM
    Monday, May 10, 2010 7:25 AM

All replies

  • I think this code here:

    http://blogs.msdn.com/astebner/pages/9763379.aspx 

    is basically registry reading to detect FW versions, so remote registry APIs should work.


    Phil Wilson
    • Marked as answer by Stefan_A Monday, May 10, 2010 7:21 AM
    Friday, May 7, 2010 6:07 PM
  • You can look via remote to your other machine and check the registry for .NET-Framework versions.

    Regards

     

    martinwy

    • Marked as answer by Stefan_A Monday, May 10, 2010 7:21 AM
    Saturday, May 8, 2010 1:33 PM
  • Hey guys,

    Indeed a remote registry check solves the issue! I'll post the code below so that others can use it also if they wish:

    /// <summary>Checks whether the .NET Framework 3.5 is installed.</summary>
    /// <param name="machineName">The machine to search on.</param>
    /// <remarks>Detection method as explained on the following page: <see cref="http://msdn.microsoft.com/library/cc160716.aspx"/></remarks>
    public static bool IsNetFrameWork35Installed(string machineName)
    {
    	RegistryKey HKLM = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, machineName);
    
    	RegistryKey framework35 = HKLM.OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5");
    
    	if (framework35 == null)
    		return false;
    
    	int keyValue = (int)framework35.GetValue("Install");
    
    	return keyValue == 1;
    }

    Thanks a lot for helping !

    Kind regards, Stefan

    • Marked as answer by YiChun Chen Tuesday, May 11, 2010 7:44 AM
    Monday, May 10, 2010 7:25 AM