Object reference not set to an instance of object App.Config

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have placed the Sql Connection in the App.Config of the project. When I
am trying to read this value from the project it is giving the error "Object
Reference not set to an instance of Object". I am calling the function in
this project from a web project. Is it due to that? My App.Config file and
Code is as follows

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="SqlConnectionString" value="TestValue" />
</appSettings>
</configuration>

Dim test as string =
System.Configuration.ConfigurationSettings.AppSettings("SqlConnectionString").ToString()

I am using this inside a private shared function.
Please let me know.

Thnx,
Sridhar.
 
I am calling the function in
this project from a web project. Is it due to that?

Yes, since the web project is looking to the web.config for the value,
not the app.config of another project.
 
Hi,

Thanks for the information. Please let me know how to change the Environment
so that it will look at App.Config of the project instead of the one that is
calling.

Thanks,
Sridhar.
 
Back
Top