Ecco il mio app.configConfigurationManager.GetSection restituisce null
<configuration>
<configSections>
<section name="procedureList" type="System.Configuration.NameValueSectionHandler, System, Version=4.0.30319, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</configSections>
<procedureList>
<add key="NAS.spBusObjGetLineProd" value="@area='Melt Shop';@endDt=?date?;@dayonly=1;@obj='Melt Shop Business Objective" />
<add key="NAS.spBusObjGetLineProd" value="@area='Cold Mill';@endDt=?date?;@dayonly=1;@obj='Cold Mill Business Objective" />
</procedureList>
<appSettings>
<add key="Connstr" value=""/>
<add key="Userid" value=""/>
<add key="Timeout" value=""/>
</appSettings>
</configuration>
Ma quando io lo chiamo in codice, sto diventando un null indietro
public void samplemethod()
{
NameValueCollection nvc = ConfigurationManager.GetSection("procedureList") as NameValueCollection;
string[] keys = nvc.AllKeys;
}
Gradirei qualsiasi aiuto sottolineando cosa ho fatto di sbagliato
stai trasmettendo in modo errato. Pubblicherò un esempio di seguito insieme a un collegamento che puoi utilizzare come riferimento – MethodMan
Se l'operazione di conversione 'as' non riesce, restituisce un valore nullo. Tuttavia, il file di configurazione nota che il tipo di sezione è 'NameValueSectionHandler': si dovrebbe eseguire il casting su questo tipo quando si chiama GetSection(). –
anche quando cambio il tipo in NameValueSectionHandler, sto ancora ottenendo un valore null – edepperson