473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Having issues reading App.config file

SAL
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.
Jun 29 '06 #1
2 6749
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" wrote:
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.

Jun 29 '06 #2
SAL
Thanks Peter. Works perfectly now.

"Peter Bromberg [C# MVP]" wrote:
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" wrote:
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.

Jun 29 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: digidalmation | last post by:
Hello all. I've been trying to get my linux server to run mod_python. It's a Mandrake 10 linux box, and apache/mod_python are installed from rpms. apache2-mod_python-2.0.48_3.1.3-1mdk...
1
by: Joe | last post by:
Hi Does anyone know of any issues about loading config files for windows forms applications? I have an application that utilizes a config file that holds my database connection string as well...
1
by: Uma Abhyankar | last post by:
Hello All, I was facing an issue with VCBuild on Beta1. Today after shifting to .NET Beta2, it looks like the issue is still not resolved :-( I have to invoke VCBuild through MSBuild on command...
3
by: spacekid | last post by:
Hi there I am exposing a c# assembly as a COM component (regasm /codebase) and calling it from classic asp. When I try to call the ConfigurationSettings.AppSettings function in the c# assembly,...
6
by: Anthony Williams | last post by:
Hi all, Am I right in thinking that if I set Server.ScriptTimeout to, say, 600 that every request for an .ASPX page will wait up to 600 seconds before responding with a "Request Timed Out"...
4
by: John Q. Smith | last post by:
I'm trying to find out some of the details behind OOP state management with SQL Server. For instance - how long does the session object live on any server? Is it created and destoyed with each...
5
by: Pete Davis | last post by:
I posted a question about this earlier, but I thought I'd take a different tack. Has anyone compiled a list of all the things that can cause setting the customErrors mode to "Off" in the web.config...
2
by: Priya | last post by:
Hi, I'm developing an ASP.NET application. I imported a C++ dll into the C# code. When I tried to access a function in that dll, application threw an exception...
1
by: vijayarl | last post by:
Hi Everyone, i have the written this logic : basically a file operation open (CONFIGFILE, "$config_file") or die; while (<CONFIGFILE>) { chomp;
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.