error of configuration section handler for system.web/authorizatio

W

william

Hi all,

I've got error "An error occurred executing the configuration section
handler for system.web/authorization" when I tried to save changes of
configuration sometimes.
Here is what I've done:
1. get authorization rule:
AuthorizationRule authorizationRule =new
System.Web.Configuration.AuthorizationRule(action);
2. add users/roles into the rule:
authorizationRule.Users.AddRange(users);
3. get configuration file:
config = WebConfigurationManager.OpenWebConfiguration(filePath) as
Configuration;
4. get section:
AuthorizationSection authorizationsection =
config.GetSection("system.web/authorization") as AuthorizationSection;
5. add rule to this section:
authorizationsection.Rules.Add(authorizationRule);
6. save changes:
config.Save();

It's wired because sometime it happens, sometime not.
Here is detail error:
"System.Configuration.ConfigurationErrorsException: An error occurred
executing the configuration section handler for system.web/authorization.
---> System.NullReferenceException: Object reference not set to an instance
of an object.\r\n at
System.Configuration.ConfigurationElement.UnMergeLockList(ConfigurationLockCollection
sourceLockList, ConfigurationLockCollection parentLockList,
ConfigurationSaveMode saveMode)\r\n at
System.Configuration.ConfigurationElement.Unmerge(ConfigurationElement
sourceElement, ConfigurationElement parentElement, ConfigurationSaveMode
saveMode)\r\n at
System.Web.Configuration.AuthorizationRule.Unmerge(ConfigurationElement
sourceElement, ConfigurationElement parentElement, ConfigurationSaveMode
saveMode)\r\n at
System.Configuration.ConfigurationElementCollection.Unmerge(ConfigurationElement
sourceElement, ConfigurationElement parentElement, ConfigurationSaveMode
saveMode)\r\n at
System.Configuration.ConfigurationElement.Unmerge(ConfigurationElement
sourceElement, Configura
tionElement parentElement, ConfigurationSaveMode saveMode)\r\n at
System.Configuration.ConfigurationSection.SerializeSection(ConfigurationElement
parentElement, String name, ConfigurationSaveMode saveMode)\r\n at
System.Configuration.MgmtConfigurationRecord.GetConfigDefinitionUpdates(Boolean
requireUpdates, ConfigurationSaveMode saveMode, Boolean forceSaveAll,
ConfigDefinitionUpdates& definitionUpdates, ArrayList&
configSourceUpdates)\r\n --- End of inner exception stack trace ---\r\n
at
System.Configuration.MgmtConfigurationRecord.GetConfigDefinitionUpdates(Boolean
requireUpdates, ConfigurationSaveMode saveMode, Boolean forceSaveAll,
ConfigDefinitionUpdates& definitionUpdates, ArrayList&
configSourceUpdates)\r\n at
System.Configuration.MgmtConfigurationRecord.SaveAs(String filename,
ConfigurationSaveMode saveMode, Boolean forceUpdateAll)\r\n at
System.Configuration.Configuration.SaveAsImpl(String filename,
ConfigurationSaveMode saveMode, Boolean forceSaveAll)\r\n at
System.Configuration.Configur
ation.Save()\r\n at AddAccessRule.AddAuthorizationRule(String filePath,
Boolean access, String[] roles, String[] users) in c:\\VSS
Tempwork\\ASPNet\\Management\\Admins\\AddAccessRule.aspx.cs:line 483"

Please help me out.

Thanks.
william
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top