WCF service on IIS.
I have got a problem with reading connection string from web.config file.
my connection string looks like this :
<connectionStrings>
<add
name="ABC"
connectionString="DEF"
providerName="GGG"
/>
</connectionStrings>
My code in Global.asax.cs :
protected void Application_Start(object sender, EventArgs e)
{
cons_Webdata = WebConfigurationManager.ConnectionStrings["ABC"].ConnectionString;
}
I have error message in “cons_Webdata = …….” :
Object reference not set to an instance of an object.
What’s wrong?
Thanks.
Try using ConfigurationManager instead of WebConfigurationManager
Otherwise, use the code sample from http://msdn.microsoft.com/en-us/library/ms178411.aspx