I’ve got a rather odd situation which is bound to something breathtakingly obvious, but it has me stumped.
Quite simply, I’m trying to load some configuration data into my app, as follows:
namespace XMLGrabberCS
{
class Grabber
{
public static void Main()
{
string test = "test";
string serverName = ConfigurationManager.AppSettings["ServerName"];
try
{
//do stuff...
Pretty straightforward stuff, except that if you query (i.e. via Quick Watch) either variable, you get a variable doesn’t exist in current context error.
If you watch ConfigurationManager.AppSettings["ServerName"] it does return the right value…
What on earth is going on here?
Are the strings referenced later on in the code? If not they could be being optimised away (unlikely if you’re in debug, but worth a check).