.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Articles >> SharePoint >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Scenario - Error on using SPWebConfigModification in SharePoint

Posted By:Jean Paul       Posted Date: August 22, 2013    Points: 200    Category: SharePoint    URL: http://www.dotnetspark.com  

In this article we will explore a possible error scenario while working with SPWebConfigModification class.

In this article I would like to update with a possible Error Scenario while working with the SPWebConfigModification class.


You are adding a new entry to the web.config file using SPWebConfigModification class.

SPWebService service = SPWebService.ContentService;
SPWebConfigModification modification = new SPWebConfigModification();

Unfortunately the following error is thrown repeatedly.

Error: XmlException was unhandled

The '[' character, hexadecimal value 0x5B, cannot be included in a name.  Line 1, position XXXXX

Root Cause

Please note that the error might not be telling about the new modification.  All the previous modifications are queued up and applied together to multiple farm servers.  So you need to check all the modification entries for any problems with their Name, Value properties.
Additionally the character and position mentioned in the error message could be different.
You can locate the exact modification entry having problem using the following property.

This property should contain all the modifications.  You can remove the wrong modification entry and use the Update() method to save the changes.  Once the problem is fixed you can re-run your new modification code.

For example if you have the wrong entry at position 13, use the following code to remove the entry and update.


Using Quick Watch

You can use the Quick Watch window to locate the problem entry.

Examine each item for the Name and Value property especially.

Additional Tip

You can always switch between different web applications using the following code.

SPWebService service = SPWebService.AdministrationService;
SPWebService service = SPWebService.ContentService;

Both the properties returns the SPWebService object associated with the name.




In this article we have explored a possible error scenario while working with SPWebConfigModification class.

 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend