简体   繁体   中英

How to change property Enable32BitAppOnWin64 of Application Pool on IIS 7 on Windows Azure?

I have project with third part library, this library made for 32-bit systems. But my project will be working on Windows Azure and I must set property Enable32BitAppOnWin64 of Application Pool to true before Windows Azure run my application. What are the ways to set this property (config, programmatically)? If I can do this only programmatically then where in code must I change it? Can I do this in event OnStart of WebRole?

I just had to do this. I used a Startup task to change this setting.

I created a batch file and added this command:

%windir%\system32\inetsrv\appcmd set config -section:applicationPools -applicationPoolDefaults.enable32BitAppOnWin64:true

I then added the batch file to run as a startup script to the azure configuration. It worked without any issues.

For more info on startup tasks see here: http://msdn.microsoft.com/en-us/library/gg456327.aspx

After adding the aforementioned command in the Startup batch file which calls powershell script, somehow the script fails at this entry and my cloud service couldn't start. I ended up changing WebRole.cs file and it worked in Azure cloud service (Windows Server 2012 R2), like so:

using Microsoft.Web.Administration;
namespace KDC.UserWeb.RoleEntryPoint
{
    {
        public override bool OnStart()
        {
            Enable32BitAppPool();
            return base.OnStart();
        }
        {
            base.Run();
        }

    public static void Enable32BitAppPool();
    {
        ServerManager serverManager = new ServerManager();
        ApplicationPoolCollection applicationPoolCollection = serverManager.ApplicationPools;
        foreach (ApplicationPool applicationPool in applicationPoolCollection)
        {
            if( !String.IsNullOrEmpty(applicationPool.Name) && applicationPool.Name[0]  != '.' )
            {
                serverManager.ApplicationPools[applicationPool.Name].Enable32BitAppOnWin64 = true;
                serverManager.CommitChanges();
            }
        }
    }

}

}

Note:
By default, there are two appPool created starts with .NET ... which will be filtered and only appPool created specific for the cloud service is selected for enabling 32 bit.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM