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

帅比萌擦擦* 提交于 2020-01-23 10:48:46

问题


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?


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/7256361/how-to-change-property-enable32bitapponwin64-of-application-pool-on-iis-7-on-win

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!