EDN Admin
Well-known member
First off I want to say that I have scoured this forum and many others trying to figure out what is causing this issue.
I inherited a C# project at work with multiple class files that hooks into a third party application to retrieve data from a database. I am trying to add a config file to the project so that clients can easily change a few settings simply by editing the values in the XML file. I have referenced the System.Configuration dll and Im not receiving any errors when I compile the project. Anyway, to the point, I have the following in my App.config file (default name chosen by VS)
<div style="overflow:auto;background-color:white;line-height:100% ! important;font-family:Courier New;font-size:11px <table style="border-width:0px;margin:2px 0px;width:99%;border-collapse:collapse;background-color:rgb(255, 255, 255)" cellpadding=0 cellspacing=0><col style="font-family:Courier New;font-size:11px;padding-left:10px;white-space:nowrap <tbody><tr><td><font style="font-size:11px </font><font style="color:blue <?</font><font style="font-size:11px xml </font><font style="color:red version</font><font style="font-size:11px =</font><font style="color:blue "1.0"</font><font style="font-size:11px </font><font style="color:red encoding</font><font style="font-size:11px =</font><font style="color:blue "utf-8"</font><font style="font-size:11px </font><font style="color:blue ?></font><font style="font-size:11px </font></td></tr><tr><td style="background-color:rgb(247, 247, 247) <font style="color:blue <</font><font style="font-size:11px configuration</font><font style="color:blue ></font><font style="font-size:11px </font></td></tr><tr><td> <font style="color:blue <</font><font style="font-size:11px appSettings</font><font style="color:blue ></font><font style="font-size:11px </font></td></tr><tr><td style="background-color:rgb(247, 247, 247) <font style="color:blue <</font><font style="font-size:11px add </font><font style="color:red key</font><font style="font-size:11px =</font><font style="color:blue "appUrl"</font><font style="font-size:11px </font><font style="color:red value</font><font style="font-size:11px =</font><font style="color:blue "Test"</font><font style="font-size:11px /> </font></td></tr><tr><td> <font style="color:blue </</font><font style="font-size:11px appSettings</font><font style="color:blue ></font><font style="font-size:11px </font></td></tr><tr><td style="background-color:rgb(247, 247, 247) <font style="color:blue </</font><font style="font-size:11px configuration</font><font style="color:blue ></font><font style="font-size:11px </font></td></tr></tbody></table>
I also have the following lines in my project code:
<div style="overflow:auto;background-color:white;line-height:100% ! important;font-family:Courier New;font-size:11px <table style="border-width:0px;margin:2px 0px;width:99%;border-collapse:collapse;background-color:rgb(255, 255, 255)" cellpadding=0 cellspacing=0><col style="font-family:Courier New;font-size:11px;padding-left:10px;white-space:nowrap <tbody><tr><td><font style="font-size:11px string urlStrng; </font></td></tr><tr><td style="background-color:rgb(247, 247, 247) <font style="color:red urlStrng</font><font style="font-size:11px = </font><font style="color:blue ConfigurationManager</font><font style="font-size:11px .AppSettings["appUrl"]; </font></td></tr></tbody></table>
I have tried many different approaches to this and no matter what ConfigurationManager.AppSettings["appUrl"] returns null. However, when I simply create a new, very basic project in Visual Studio (2005) with the exact same App.config file everything works just fine:
<div style="overflow:auto;background-color:white;line-height:100% ! important;font-family:Courier New;font-size:11px <table style="border-width:0px;margin:2px 0px;width:99%;border-collapse:collapse;background-color:rgb(255, 255, 255)" cellpadding=0 cellspacing=0><col style="font-family:Courier New;font-size:11px;padding-left:10px;white-space:nowrap <tbody><tr><td><font style="font-size:11px private void button1_Click(object sender, EventArgs e) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247) { </td></tr><tr><td> string urlStrng; </td></tr><tr><td style="background-color:rgb(247, 247, 247) <font style="color:red urlStrng</font><font style="font-size:11px = </font><font style="color:blue ConfigurationManager</font><font style="font-size:11px .AppSettings["appUrl"]; </font></td></tr><tr><td> MessageBox.Show(urlStrng); </td></tr><tr><td style="background-color:rgb(247, 247, 247) } </td></tr></tbody></table>
What am I missing?
View the full article
I inherited a C# project at work with multiple class files that hooks into a third party application to retrieve data from a database. I am trying to add a config file to the project so that clients can easily change a few settings simply by editing the values in the XML file. I have referenced the System.Configuration dll and Im not receiving any errors when I compile the project. Anyway, to the point, I have the following in my App.config file (default name chosen by VS)
<div style="overflow:auto;background-color:white;line-height:100% ! important;font-family:Courier New;font-size:11px <table style="border-width:0px;margin:2px 0px;width:99%;border-collapse:collapse;background-color:rgb(255, 255, 255)" cellpadding=0 cellspacing=0><col style="font-family:Courier New;font-size:11px;padding-left:10px;white-space:nowrap <tbody><tr><td><font style="font-size:11px </font><font style="color:blue <?</font><font style="font-size:11px xml </font><font style="color:red version</font><font style="font-size:11px =</font><font style="color:blue "1.0"</font><font style="font-size:11px </font><font style="color:red encoding</font><font style="font-size:11px =</font><font style="color:blue "utf-8"</font><font style="font-size:11px </font><font style="color:blue ?></font><font style="font-size:11px </font></td></tr><tr><td style="background-color:rgb(247, 247, 247) <font style="color:blue <</font><font style="font-size:11px configuration</font><font style="color:blue ></font><font style="font-size:11px </font></td></tr><tr><td> <font style="color:blue <</font><font style="font-size:11px appSettings</font><font style="color:blue ></font><font style="font-size:11px </font></td></tr><tr><td style="background-color:rgb(247, 247, 247) <font style="color:blue <</font><font style="font-size:11px add </font><font style="color:red key</font><font style="font-size:11px =</font><font style="color:blue "appUrl"</font><font style="font-size:11px </font><font style="color:red value</font><font style="font-size:11px =</font><font style="color:blue "Test"</font><font style="font-size:11px /> </font></td></tr><tr><td> <font style="color:blue </</font><font style="font-size:11px appSettings</font><font style="color:blue ></font><font style="font-size:11px </font></td></tr><tr><td style="background-color:rgb(247, 247, 247) <font style="color:blue </</font><font style="font-size:11px configuration</font><font style="color:blue ></font><font style="font-size:11px </font></td></tr></tbody></table>
I also have the following lines in my project code:
<div style="overflow:auto;background-color:white;line-height:100% ! important;font-family:Courier New;font-size:11px <table style="border-width:0px;margin:2px 0px;width:99%;border-collapse:collapse;background-color:rgb(255, 255, 255)" cellpadding=0 cellspacing=0><col style="font-family:Courier New;font-size:11px;padding-left:10px;white-space:nowrap <tbody><tr><td><font style="font-size:11px string urlStrng; </font></td></tr><tr><td style="background-color:rgb(247, 247, 247) <font style="color:red urlStrng</font><font style="font-size:11px = </font><font style="color:blue ConfigurationManager</font><font style="font-size:11px .AppSettings["appUrl"]; </font></td></tr></tbody></table>
I have tried many different approaches to this and no matter what ConfigurationManager.AppSettings["appUrl"] returns null. However, when I simply create a new, very basic project in Visual Studio (2005) with the exact same App.config file everything works just fine:
<div style="overflow:auto;background-color:white;line-height:100% ! important;font-family:Courier New;font-size:11px <table style="border-width:0px;margin:2px 0px;width:99%;border-collapse:collapse;background-color:rgb(255, 255, 255)" cellpadding=0 cellspacing=0><col style="font-family:Courier New;font-size:11px;padding-left:10px;white-space:nowrap <tbody><tr><td><font style="font-size:11px private void button1_Click(object sender, EventArgs e) </font></td></tr><tr><td style="background-color:rgb(247, 247, 247) { </td></tr><tr><td> string urlStrng; </td></tr><tr><td style="background-color:rgb(247, 247, 247) <font style="color:red urlStrng</font><font style="font-size:11px = </font><font style="color:blue ConfigurationManager</font><font style="font-size:11px .AppSettings["appUrl"]; </font></td></tr><tr><td> MessageBox.Show(urlStrng); </td></tr><tr><td style="background-color:rgb(247, 247, 247) } </td></tr></tbody></table>
What am I missing?
View the full article