【问题标题】:Programmatically create Application Pool, error setting "ManagedPipelineMode"以编程方式创建应用程序池,错误设置“ManagedPipelineMode”
【发布时间】:2013-09-03 19:24:44
【问题描述】:

我正在使用以下代码以编程方式为 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 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)

【问题讨论】:

    标签: c# iis iis-6 application-pool directoryentry


    【解决方案1】:

    事实证明,我的问题比我想象的更根本。首先,IIS 6 不支持集成管道模式,所以开关ManagedPipelineMode 甚至都不存在。此外,Enable32BitAppOnWin64 也不以这种方式存在,要打开该功能,必须运行命令 (https://web.archive.org/web/20160313115849/http://extended64.com/blogs/rhoffman/archive/2005/05/10/482.aspx)

    【讨论】:

      猜你喜欢
      • 2011-01-10
      • 1970-01-01
      • 2010-09-19
      • 1970-01-01
      • 2011-09-09
      • 2018-02-21
      • 1970-01-01
      • 2015-01-22
      • 2011-07-14
      相关资源
      最近更新 更多