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

I have application that adds a Farm feature so Sharepoint 2010. When you configure it, some entries are added to the web.config file located in "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\WebServices\SecurityToken" Whenever I deactivate the farm feature from the Sharepoint Central Administration interface (System Settings\Manage Farm Features) those entries will be deleted properly from the web.config file. The problem I have is that I want to be able to deactivate the feature programatically so I built an uninstaller that will deactivate all the features created by my .wsp and retract and remove the solution, but when it deactivates the farm feature, the entries made to the web.config file that I previously mentioned are not deleted. I use the folowing line to deactivate the feature :

SPWebService.AdministrationService.Features.Remove(feature.Definition.Id, true);

Let me know if you got any idea or need more information. Thanks.

share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

Alex,

Since you are removing feature programmatically, you can use SPWebConfigModification to remove web config settings programmatically too!

Here is a nice article:
SharePoint: How to use SPWebConfigModification class

I hope this helps

share|improve this answer
    
Thanks a lot for the answer! I've had a look at the application that I wished to uninstall programmatically and I finally found out that the problem was that it used SPContext in order to delete those specific web.config modification. So when my external application tried to deactivate the feature, SPContext was null so that part of the code didn't execute at all. I don't have enough rep to upvote your answer but thanks a lot anyways. –  Alex Nov 29 '12 at 20:04
    
No problem, glad it helped! –  Arsalan Adam Khatri Nov 29 '12 at 20:26
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.