以编程方式创建应用程序池,错误设置为“ ManagedPipelineMode”

问题描述 投票:0回答:1

我正在使用以下代码以编程方式为IIS 6(Windows Server 2003R2)创建应用程序池,但在尝试设置ManagedPipelineMode的行上出现错误,>

尝试1

        string metabasePath = @"IIS://localhost/W3SVC/AppPools";

        DirectoryEntry apppools = new DirectoryEntry(metabasePath);
        DirectoryEntry newpool = apppools.Children.Add(AppPoolName, "IIsApplicationPool");
        newpool.Properties["managedRuntimeVersion"].Value = "v4.0";
        newpool.InvokeSet("ManagedPipelineMode", new Object[] { 0 }); //exception thrown on this line
        newpool.Properties["Enable32BitAppOnWin64"].Value = true;
        if (!string.IsNullOrEmpty(username))
        {
            newpool.Properties["AppPoolIdentityType"].Value = 3;
            newpool.Properties["WAMUserName"].Value = username;
            newpool.Properties["WAMUserPass"].Value = password;
        }
        newpool.CommitChanges();

尝试2

        string metabasePath = @"IIS://localhost/W3SVC/AppPools";

        DirectoryEntry apppools = new DirectoryEntry(metabasePath);
        DirectoryEntry newpool = apppools.Children.Add(AppPoolName, "IIsApplicationPool");
        newpool.Properties["managedRuntimeVersion"].Value = "v4.0";
        newpool.Properties["ManagedPipelineMode"][0] = 0; //exception thrown on this line
        newpool.Properties["Enable32BitAppOnWin64"].Value = true;
        if (!string.IsNullOrEmpty(username))
        {
            newpool.Properties["AppPoolIdentityType"].Value = 3;
            newpool.Properties["WAMUserName"].Value = username;
            newpool.Properties["WAMUserPass"].Value = password;
        }
        newpool.CommitChanges();

无论哪种方式都抛出相同的异常。

Exception:

Exception from HRESULT: 0x80005006
    at System.DirectoryServices.Interop.UnsafeNativeMethods.IAds.PutEx(Int32 lnControlCode, String bstrName, Object vProp)
    at System.DirectoryServices.PropertyValueCollection.OnClearComplete()
    at System.DirectoryServices.PropertyValueCollection.set_Value(Object value)

我正在使用以下代码以编程方式为IIS 6(Windows Server 2003R2)创建应用程序池,但在尝试设置ManagedPipelineMode尝试1 ...的行上出现错误,

c# iis iis-6 application-pool directoryentry
1个回答
0
投票
事实证明,我的问题比我想象的要根本。首先,IIS 6不支持集成管道模式,因此甚至没有开关ManagedPipelineMode。另外,Enable32BitAppOnWin64也不以这种方式存在,要启用该功能,必须运行命令(https://web.archive.org/web/20160313115849/http://extended64.com/blogs/rhoffman/archive/2005/05/10/482.aspx
© www.soinside.com 2019 - 2024. All rights reserved.