Having issues reading App.config file

G

Guest

Below is similar code that I am have and the line "myDataConnect mydata = new
myDataConnect(ConfigurationSettings.AppSettings["connectSQL"]);" is what I am
having trouble with.

The syntax is correct and I get no errors, but it is not finding the Key
“connectSQL†or any key for that matter in my app.config. It returns a NULL
value. Besides the Namespace imports I have defined, I also have 4
references set up to:

System
System.Data
System.Data.OracleClient
System.XML

I am using a Windows test App solution with Framework 1.1 to test my Class
Library Project that has been added to the solution, which contains the
App.config, myDataConnect.cs, and myClass.cs.

#region Namespace imports

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.IO;
using System.Text;
using System.Xml;

#endregion

public class MyClass

{
#region Public Methods

public void myFunction()

{
myDataConnect mydata = new
myDataConnect(ConfigurationSettings.AppSettings["connectSQL"]);
myDataSet datData =
mydata.getSqlDataSet("sp_myStoredProcedure");

}

#endregion

}

I am not sure why it’s not finding my Key in the app.config file.

Thanks for the help in advance.
 
G

Guest

App.config files are not read by DLL Assemblies - only be EXE assemblies.
Put the app.config in the Test EXE app project, and it will work fine.

Peter
 
G

Guest

Thanks Peter. Works perfectly now.

Peter Bromberg said:
App.config files are not read by DLL Assemblies - only be EXE assemblies.
Put the app.config in the Test EXE app project, and it will work fine.

Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




SAL said:
Below is similar code that I am have and the line "myDataConnect mydata = new
myDataConnect(ConfigurationSettings.AppSettings["connectSQL"]);" is what I am
having trouble with.

The syntax is correct and I get no errors, but it is not finding the Key
“connectSQL†or any key for that matter in my app.config. It returns a NULL
value. Besides the Namespace imports I have defined, I also have 4
references set up to:

System
System.Data
System.Data.OracleClient
System.XML

I am using a Windows test App solution with Framework 1.1 to test my Class
Library Project that has been added to the solution, which contains the
App.config, myDataConnect.cs, and myClass.cs.

#region Namespace imports

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.IO;
using System.Text;
using System.Xml;

#endregion

public class MyClass

{
#region Public Methods

public void myFunction()

{
myDataConnect mydata = new
myDataConnect(ConfigurationSettings.AppSettings["connectSQL"]);
myDataSet datData =
mydata.getSqlDataSet("sp_myStoredProcedure");

}

#endregion

}

I am not sure why it’s not finding my Key in the app.config file.

Thanks for the help in advance.
 

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

Top