fix null reference error when configuration setting specified by "keyName" parameter doesnt exist.
#79
This commit is contained in:
parent
23ade491e6
commit
20f0ccb211
@ -1,4 +1,5 @@
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
|
||||
namespace ConfigurationHandler
|
||||
{
|
||||
@ -7,7 +8,9 @@ namespace ConfigurationHandler
|
||||
public static string GetConfiguration(string keyName)
|
||||
{
|
||||
var appSettings = ConfigurationManager.OpenExeConfiguration(System.Reflection.Assembly.GetEntryAssembly().Location).AppSettings;
|
||||
return appSettings.Settings[keyName].Value;
|
||||
if(appSettings.Settings.AllKeys.Contains(keyName))
|
||||
return appSettings.Settings[keyName].Value;
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user