I am changing the app.config file section in Visual Studio 2013. The program language is C#, .net framework is 4.0, the program type is Windows Service.
This is my code:
        #region ChangeConfig
        /// <summary>
        /// 
        /// </summary>
        /// <param name="createdTime"></param>
        [TestCase("2015-06-10 14:37:59")]
        public void ChangeConfiguration(string createdTime)
        {                
            string assemblyConfigFile = Assembly.GetEntryAssembly().Location;
            string appDomainConfigFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);  
            AppSettingsSection appSettings = (AppSettingsSection)config.GetSection("appSettings");
            appSettings.Settings.Remove("queryTime");
            appSettings.Settings.Add("queryTime", createdTime);                
            config.Save();
            ConfigurationManager.RefreshSection("configuration");
        }
        #endregion
The problem is: when the program run to
string assemblyConfigFile = Assembly.GetEntryAssembly().Location
there is an error:
object reference not set to instance of object
How could this be?
PS:I am debugging under NUnit,the version is 2.6.4.
And this is my App.config content:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="interval" value="5"/>
    <add key="queryTime" value="2015-06-10 14:37:59"/>
    <add key="_TimerInterval" value="5000"/>
  </appSettings>
</configuration>
 
    