异常是    拒绝访问。 (异常来自 HRESULT:0x80070005 (E_ACCESSDENIED))public static String CreateNewApplicationPool(string AppPoolName,string Username,string Password)
        {
            try
            {
                DirectoryEntry newpool;
                string enPath = string.Format("IIS://{0}/W3SVC/AppPools", HostName);
                DirectoryEntry apppools = GetDirectoryEntry(enPath);
                newpool = apppools.Children.Add(AppPoolName, "IIsApplicationPool");
                newpool.Properties["WAMUserName"][0] = Username;
                newpool.Properties["WAMUserPass"][0] = Password;
                newpool.Properties["AppPoolIdentityType"][0] = "3";
                newpool.CommitChanges();
                return "true";
            }
            catch(Exception ex)
            {
                return ex.Message;//false;
                throw;
            }
        }