Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

We've two features both are designed to update (and modify) the web.config. One feature doesn't have any interface it is a SPJob which run on feature activation and copy user controls into web application virtual directory and update web.config. The second feature has a interface which is designed to configure database (or connect with) for user controls.

For deployment, there is a single batch file which do the complete web application installation like create a site, install all third-party components etc etc. And those two features activation command is also included.

The problem we are having is when we confirm the first feature changes in the web.config which it does silently we can see there. Now, we go and configure our database for custom controls. This second feature add up an Application Page where we provide all required credential. We also confirm the database creation from SQL Server Management Studio. Now, we open the web.config again and looking for the changes which we expect - a connection string it is there but the changes which was made by our first feature is gone!

The command we called to commit the web.config changes in both features is:

webApp.WebService.ApplyWebConfigModifications();

Could you help what we are doing wrong here and what should we do to the features so they avoid overwrite each other changes?

Thanks.

share|improve this question

1 Answer 1

Are both features activated just after each other in a batch file?

If this is the case this could be your problem. SPWebConfigModification class has issues with race conditions. In other words you should not deploy several solutions that write to web.config in the same batch job as the outcome can cause unpredictable results.

You can test this by manually activating each feature by itself and see if this makes the problem go away.

If i use SPWebConfigModification i try to keep them into one feature, that contains all modifications, or ensure that only one modification is done at the time.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.