none
How to check if WCF 4.5 is installed on Windows 2008 server machine using c# RRS feed

  • Question

  • I need to write a program to check if WCF 4.5 is installed and activated on 2008 machine or not. If not then I need to activate WCF 4.5 using C#. 

    How to detect whether WCF 4.5 is installed and activated on windows 2008 machine, using C#?

    Monday, November 24, 2014 8:38 AM

All replies

  • Hi,

    For this scenario, Windows Communication Foundation (WCF) is a feature of Windows Server® 2008. It can be activated by using the Server Manager's "Add Features Wizard":

    http://www.iis.net/learn/web-hosting/configuring-servers-in-the-windows-web-platform/windows-communication-framework-wcf

    If you want to check if WCF 4.5 is installed on Windows 2008 server machine by programming, you may try to refer to the Win32_ServerFeature class. The Win32_ServerFeature class represents the features installed on a computer running Windows Server. This class can be used by developers and administrators who need to automate the process of determining the features installed on a set of server computers. Instances of this class are not available on client computers.

    For more detailed information, you could refer to:

    http://msdn.microsoft.com/en-us/library/cc280268(v=vs.85).aspx

    http://blogs.msdn.com/b/patricka/archive/2008/03/05/detecting-what-server-roles-are-installed-on-windows-server-2008.aspx

    Regards

    Tuesday, November 25, 2014 6:01 AM
    Moderator
  • Hi Shwan Zhao,

    This works for WCF 3.5 on Windows 2008 Server machine but DO NOT works for WCF 4.5 on Windows 2008 Server machine.

    ManagementObjectSearcher.Get() returns the ID of WCF 3.5 related features (221,222,223) but DO NOT returns ID of WCF 4.5 related features (420, 421, 422, 423, 424, 425).

    Please share the code snippet if it works for you.

    Tuesday, November 25, 2014 6:55 AM
  • Wednesday, November 26, 2014 9:05 AM
  • Hi LemonStreet,

    Thanks for the link, but that does not solves the actual problem.

    WMI query works for detecting WCF 3.5 on Windows 2008 machine and also works for detecting WCF 4.5 on Windows 2012 machine, but it does not works for detecting WCF 4.5 on Windows 2012 machine.

    Thursday, November 27, 2014 8:46 AM
  • Look here:
    http://msdn.microsoft.com/en-us/library/hh925568(v=vs.110).aspx

    And here:

    http://msdn.microsoft.com/en-us/library/bb822049(v=vs.110).aspx

    Basically:
    // Retrieve .Net version
    string path = @"HKEY_LOCAL_MACHINE\SOFTWARE\";
    if (System.Environment.Is64BitOperatingSystem == true)
    {
      path += @"Wow6432Node\";
    }
    try
    {
      int t2 = (int)Microsoft.Win32.Registry.GetValue(path + @"Microsoft\NET Framework Setup\NDP\v4\Full\", "Release", "-");
      Trace.WriteLine(".Net Version: " + temp + "-" + t2.ToString());
    }
    catch (NullReferenceException nre)
    {
    ...
    }

    You should get something like this:

    .Net Version: 4.0.30319.34014-378675

    378675 tells you that version 4.5.1 is running on win 8.1


    Useful Software, Inc. Celebrating 25 years of software solutions.

    • Marked as answer by Shawn ZhaoModerator Thursday, December 4, 2014 11:29 AM
    • Unmarked as answer by rmagarwal Thursday, December 4, 2014 11:40 AM
    Saturday, November 29, 2014 1:49 AM
  • Again, this question is not about finding the .Net Framework version.

    This question is about to find if WCF 4.5 is activated on Windows 2008 machine? 

    Posting again the original question:

    "I need to write a program to check if WCF 4.5 is installed and activated on 2008 machine or not. If not then I need to activate WCF 4.5 using C#.

    How to detect whether WCF 4.5 is installed and activated on windows 2008 machine, using C#?"

    Thursday, December 4, 2014 11:39 AM
  • Hi,

    do you try Win32_ServerFeature? Below is my code snippet

     try
                {
                    string text = "";

                    ManagementClass serviceClass = new ManagementClass("Win32_ServerFeature");
                    foreach (ManagementObject feature in serviceClass.GetInstances())
                    {
                            text = text + feature["ID"].ToString() + "\r\n";
                    }

                    System.IO.File.WriteAllText(@"C:\temp\WriteText.txt", text);

                   
                }
                catch (ManagementException)
                {
                    // The most likely cause of this is that this is being called from an
                    // operating system that is not a server operating system.
                }

     the possible values of the ID property can be refered from : http://msdn.microsoft.com/en-us/library/cc280268(v=vs.85).aspx


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Friday, December 5, 2014 10:21 AM
  • Yes, I tried the above way too.

    It gives 221, 222, and 223 on Win 2K8 machine and 420, 421, 422, 423, 424, 425 on Win 2K12 machine.

    But it does not gives 420, 421, 422, 423, 424, 425 on Win 2K8 machine although .Net Framework 4.5.1 is installed on that Win 2K8 machine and WCF 4.5 is also enabled.

    Friday, December 5, 2014 11:35 AM
  • Dear,

    Your question falls into a category which requires a more in-depth level of support.  Please visit the below link to see the various free and paid support options that are available to better meet your needs. http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Monday, December 8, 2014 8:32 AM