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

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.
 
K

KJ

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.
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top