problem with ConfigurationManager.GetSection

  • Thread starter Thread starter Troy Fruetel
  • Start date Start date
T

Troy Fruetel

I am supporting a web site that has the following line of code:

Hashtable envPortal = (Hashtable)
ConfigurationManager.GetSection("environment");

For some reason, this line of code has no problem when I am running on the
server and browse to localhost first, but if I browse to the same site and
use the server name instead of localhost, the above line fails with
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.


My config file looks like this:

<configSections>
<section name="environment" type="PortalEnvironment"/>
</configSections>
..
..
..
<environment>
<!-- local -->
<Configuration url="http://localhost">
<add key="ConnectionString.RSPortal" value="valid connection string"/>
<add key="ConnectionString.FinSolAccRec" value="valid connection string"/>
<add key="ConnectionString.GATEFinSol" value="valid connection string"/>
<add key="ReportingServices.DAL1AMVDAP018" domain="gmacm"
login="svc_gate_services_d" password="xxx"/>
<add key="ReportingServices.SMSPAI1131LM16" domain="gmacm"
login="svc_gate_services_d" password="xxx"/>
<add key="ReportingServices.SMSPAP1130LM13" domain="rfc" login="mcummin"
password="xxx"/>
</Configuration>
<!-- shared -->
<Configuration url="http://DAL1AMVDAP018">
<add key="ConnectionString.RSPortal" value="valid connection string"/>
<add key="ConnectionString.FinSolAccRec" value="valid connection string"/>
<add key="ConnectionString.GATEFinSol" value="valid connection string"/>
<add key="ReportingServices.DAL1AMVDAP018" domain="gmacm"
login="svc_gate_services_d" password="xxx"/>
<add key="ReportingServices.SHO1AMVMAP014" domain="gmacm"
login="svc_gate_services_m" password="xxx"/>
<add key="ReportingServices.DAL1AMVPAP017" domain="gmacm"
login="svc_gate_services" password="xxx"/>
</Configuration>
</environment>
 
Back
Top