Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7829469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:46:37+00:00 2026-06-02T10:46:37+00:00

I want to change Enable32BitAppOnWin64 property using C#. I know that the way of

  • 0

I want to change Enable32BitAppOnWin64 property using C#. I know that the way of interacting with IIS 6 and IIS 7 are different. but I need the solution for both versions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T10:46:39+00:00Added an answer on June 2, 2026 at 10:46 am

    There are a few differences in programmatically managing IIS 6 and IIS 7.

    IIS 6 is programmatically managed using the DirectoryEntry class and the metabase database API.

    IIS 7 is managed using the Microsoft.Web.Administration assembly
    and the ServerManager class.

    Furthermore IIS 6 is not able to run both 64 bit and 32 bit worker processes
    at the same time (see this MSDN BLOG).
    So setting Enable32BitAppOnWin64 to true for IIS 6 means that all worker
    processes (all application pools) are running as 32 bit processes.

    IIS 7 is capable of running 64 bit and 32 bit worker processes at the same time.
    This means that you set Enable32BitAppOnWin64 for a specific application pool
    and not for all application pools.

    You also have to detect the version of IIS in order to use the correct API.
    This can be done by reading the following DWORD values from the registry
    (for more information see Learn IIS):

    HKLM\Software\Microsoft\InetStp\MajorVersion and
    HKLM\Software\Microsoft\InetStp\MinorVersion
    

    So, here is some code to set Enable32BitAppOnWin64 for IIS 6 and IIS 7
    (please note that you have to reference the Microsoft.Web.Administration
    and System.DirectoryServices assemblies in your Visual Studio project):

    private static Version GetIISVerion()
    {
      using (RegistryKey inetStpKey = 
        Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\InetStp"))
      {
        int majorVersion = (int)inetStpKey.GetValue("MajorVersion");
        int minorVersion = (int)inetStpKey.GetValue("MinorVersion");
    
        return new Version(majorVersion, minorVersion);
      }
    }
    
    private static void Enable32BitAppOnWin64IIS7(string appPoolName)
    {
      Console.Out.WriteLine("Setting Enable32BitAppOnWin64 for {0} (IIS7)", appPoolName);
      using (ServerManager serverMgr = new ServerManager())
      {
        ApplicationPool appPool = serverMgr.ApplicationPools[appPoolName];
        if (appPool == null)
        {
          throw new ApplicationException(String.Format("The pool {0} does not exist", appPoolName));
        }
    
        appPool.Enable32BitAppOnWin64 = true;
        serverMgr.CommitChanges();
      }
    }
    
    private static void Enable32BitAppOnWin64IIS6(string serverName)
    {
      Console.Out.WriteLine("Setting Enable32BitAppOnWin64 for IIS6");
      using (DirectoryEntry appPools = 
        new DirectoryEntry(String.Format("IIS://{0}/W3SVC/AppPools", serverName)))
      {
        appPools.Properties["Enable32BitAppOnWin64"].Value = true;
    
        appPools.CommitChanges();
      }
    }    
    
    public static void Enable32BitAppOnWin64(string serverName, string appPoolName)
    {
      Version v = GetIISVerion(); // Get installed version of IIS
    
      Console.Out.WriteLine("IIS-Version: {0}", v);
    
      if (v.Major == 6) // Handle IIS 6
      {
        Enable32BitAppOnWin64IIS6(serverName);
        return;
      }
    
      if (v.Major == 7) // Handle IIS 7
      {        
        Enable32BitAppOnWin64IIS7(appPoolName);
        return;
      }
    
      throw new ApplicationException(String.Format("Unknown IIS version: {0}", v.ToString()));
    }
    
    
    static void Main(string[] args)
    {
      Enable32BitAppOnWin64(Environment.MachineName, "DefaultAppPool");
    }
    

    I should also mention that there is a possibility to use the metabase API
    for IIS 7, too. On Windows Server 2008 operating systems you can
    install a role service called “IIS 6 Management Compatibility”. This
    role service enables you to use the “old” IIS 6 API to manage IIS 7.

    If “IIS 6 Management Compatibility” is an option for you change the
    function Enable32BitAppOnWin64IIS7 as follows:

    private static void Enable32BitAppOnWin64IIS7(string serverName, string appPoolName)
    {
      Console.Out.WriteLine("Setting Enable32BitAppOnWin64 for {0} (IIS7)", appPoolName);
    
      using (DirectoryEntry appPools = 
        new DirectoryEntry(String.Format("IIS://{0}/W3SVC/AppPools/{1}", serverName, appPoolName)))
      {
        appPools.Properties["Enable32BitAppOnWin64"].Value = true;
    
        appPools.CommitChanges();
      }
    }
    

    Of course, then you do not have to reference the Microsoft.Web.Administration assembly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want change title's color of navigation controller but i dont know why doesn't
I use UITableView and I want change the height of different cells. But I
I implemented the Line graph using the achartengine. But i want change the line
I want to change the background color of a textbox as an indicator that
I want to change content of a Button in XAML using a DataTrigger. Conditionally
I want change the default code generator of ASP.NET MVC and use Hanselman Way
I'm programming a Live wallpaper displaying a simple image that I want change every
I want change my class=value on select option using jQuery Example <select name=color_scheme id=color_scheme>
I want change latin number to persian number and add commas, but it don't
I want change background picture(a div) with javascript that I will take from database.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.