SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am writing a feature, on activation it must create an entry in a list for every entry in a document library. I am using a webservice to get to the list which is on another sharepoint site. I am using the configurationmanager to get my credentials for the service. What goes wrong is, when I debug I get an object reference not set error. When I comment out my

    subscriberListService.Credentials = new NetworkCredential(ConfigurationManager.AppSettings["Username"].ToString(), ConfigurationManager.AppSettings["Password"].ToString(), ConfigurationManager.AppSettings["Domain"].ToString());

line and activate, it works fine. If I put a breakpoint in my code just before the commented out line listed above and use the immediate window to execute the above line of code, it works fine, it finds the entries in the appsettings section in the config file and correctly applies them to the subscriberListService credentials.

Why is it having configuration manager issues on feature activation?

share|improve this question

I suspect you have saved your app settings in the wrong web.config. You need to be cognicant of the app domain being used here. In other words, if the call is originated from a web service, then the web service App domain (and subsequent web.config) is used. Make sure you add the AppSettings for Username, Password,Domain in the correct web.config.

Also, If you are using Sharepoint 2010, you shouldn't be saving Passwords andd username in web configs as it's not secure. Rather make use of the Secure Store service. Read more here:

share|improve this answer
If i was saving the settings in the wrong .config file then it would also throw an object reference error when executing the code in the immediate window, I'll investigate the secure store service, thanks! – Linton Caldecott Feb 4 '13 at 9:58

Your Answer


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.