I was using the following code before which was working fine.
if (output == "Success")
terminate();
Configuration config =
ConfigurationManager.OpenExeConfiguration(System.Windows.Forms.Application.ExecutablePath);
var setting = config.AppSettings.Settings["PATH"];
Because of a change in requirement, i commented out the function call terminate()
if (output == "Success")
//terminate();
Configuration config =
ConfigurationManager.OpenExeConfiguration(System.Windows.Forms.Application.ExecutablePath);
var setting = config.AppSettings.Settings["PATH"];
This throws the error Embedded statement cannot be a declaration or labeled statement in the config variable declaration line. And another error is thrown Use of unassigned local variable 'config' in the setting variable declaration line.
Since terminate() is commented, it tries to take the next single statement as the if condition block.
The solution is to comment out full if condition block.
//if (output == "Success")
//terminate();
Configuration config =
ConfigurationManager.OpenExeConfiguration(System.Windows.Forms.Application.ExecutablePath);
var setting = config.AppSettings.Settings["PATH"];
Another solution is to put curly braces depending on the requirement.
if (output == "Success")
{
//terminate();
Configuration config =
ConfigurationManager.OpenExeConfiguration(System.Windows.Forms.Application.ExecutablePath);
var setting = config.AppSettings.Settings["PATH"];
}