2

I am making an application that creates several application pools and webs on IIS.

I need to enable 32 bit applications in one of them.

How can I do it programatically?

TiraULTI
  • 199
  • 1
  • 2
  • 15
  • 1
    What do you mean "programatically"? You mean from within an app running on that pool? I highly doubt that you can change that from within the pool. – D Stanley Nov 23 '16 at 15:45
  • [This article](https://blogs.msdn.microsoft.com/rakkimk/2007/11/03/iis7-running-32-bit-and-64-bit-asp-net-versions-at-the-same-time-on-different-worker-processes/) shows how to do it from the command line (among other methods). – D Stanley Nov 23 '16 at 15:46
  • 1
    powershell can do this, see https://forums.iis.net/t/1181048.aspx , using c# only I don't think it is possible you need AppCmd.exe anyway – A.T. Nov 23 '16 at 15:47
  • Did you have a look at this on stackOverflow: http://stackoverflow.com/questions/10170402/how-to-enable-32-bit-applications-mode-in-iis-6-and-iis-7-using-c-sharp – LjCode Nov 23 '16 at 15:51
  • The answer was found here http://stackoverflow.com/questions/10170402/how-to-enable-32-bit-applications-mode-in-iis-6-and-iis-7-using-c-sharp Thanks – TiraULTI Nov 23 '16 at 17:29

1 Answers1

2

You did not specify IIS version. For old ones, one could use DirectoryServices as described here: https://msdn.microsoft.com/en-us/library/ms525598%28v=vs.90%29.aspx?f=255&MSPPError=-2147217396

The property for 32 bit should be "Enable32BitAppOnWin64" if I rememeber correctly.

For IIS 7+, you should use Microsoft.Web.Administration namespace as described here: https://www.iis.net/learn/manage/scripting/how-to-use-microsoftwebadministration

This is a managed api. Check the reference posted or experiment a little.

Also, if you have IIS Metabase Compatibility installed with IIS 7, the first solution should work too. (Not available on newer systems)

Example using DirectoryServices:

var appPool = new DirectoryEntry(string.Format("IIS://{0}/w3svc/apppools/DefaultAppPool", Environment.MachineName));
            //Integrated mode
            appPool.InvokeSet("ManagedPipelineMode", new object[] { 0 });
            appPool.InvokeSet("MaxProcesses", new object[] { 1 });
            //Enable 32-bit Applications
            appPool.InvokeSet("Enable32BitAppOnWin64", new object[] { true });

            appPool.CommitChanges();
Roland
  • 972
  • 7
  • 15