0

次のコードを使用してプログラムで 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)
4

1 に答える 1