I try to rethrow an exception, but it’s not working.
I get ‘Exception was unhandled’ error in visual studio.
public KeyValueConfigurationCollection getMyAppSetting()
{
Configuration config;
ConfigurationFileMap configFile;
try
{
configFile = new ConfigurationFileMap(ConfigurationManager.OpenMachineConfiguration().FilePath);
config = ConfigurationManager.OpenMappedMachineConfiguration(configFile);
AppSettingsSection MyAppSettingSection = (AppSettingsSection)config.GetSection("xxx/appSettings");
MyAppSettingSection.SectionInformation.AllowExeDefinition = ConfigurationAllowExeDefinition.MachineToRoamingUser;
return MyAppSettingSection.Settings;
}
catch (Exception ex)
{
logger.Fatal("...");
throw;
}
}
This method belong to a class library, and i call it from a console application.
Please, help me.
Thanks.
It is working as expected.
You catch, then rethrow the exception – you are now not handling the rethrown exception. That’s why you are getting the error.