473,698 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Having issues reading App.config file

SAL
Below is similar code that I am have and the line "myDataConn ect mydata = new
myDataConnect(C onfigurationSet tings.AppSettin gs["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.Ora cleClient
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.c s, and myClass.cs.

#region Namespace imports

using System;
using System.Collecti ons;
using System.Configur ation;
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(C onfigurationSet tings.AppSettin gs["connectSQL "]);
myDataSet datData =
mydata.getSqlDa taSet("sp_mySto redProcedure");

}

#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 6767
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 "myDataConn ect mydata = new
myDataConnect(C onfigurationSet tings.AppSettin gs["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.Ora cleClient
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.c s, and myClass.cs.

#region Namespace imports

using System;
using System.Collecti ons;
using System.Configur ation;
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(C onfigurationSet tings.AppSettin gs["connectSQL "]);
myDataSet datData =
mydata.getSqlDa taSet("sp_mySto redProcedure");

}

#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 "myDataConn ect mydata = new
myDataConnect(C onfigurationSet tings.AppSettin gs["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.Ora cleClient
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.c s, and myClass.cs.

#region Namespace imports

using System;
using System.Collecti ons;
using System.Configur ation;
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(C onfigurationSet tings.AppSettin gs["connectSQL "]);
myDataSet datData =
mydata.getSqlDa taSet("sp_mySto redProcedure");

}

#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
2920
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 apache2-2.0.48-6mdk The rpm installed the python module as: /usr/lib/apache2-extramodules/mod_python.so And added a config file for apache:
1
2727
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 as other user settings. With the original VS.NET, when loading the application through the IDE debugger everything went as planned and the config file was loaded. Now with VS.NET 2003 it seems that when I run the debugger the config file
1
2069
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 prompt. I have following issue: Issue: -------- MSBuild can invoke VCBuild internally. However it invokes VCBuild without
3
2426
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, it does not return the values from my web.config. The web.config is located in the root of the web application. The classic asp page that calls the COM exposed c# assembly is located in a subfolder called message. Can anyone help me out here?
6
16135
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" exception? If I am right, then something screwy is going on with my server. Allow me to explain. I have a wee page that sends 30 emails out to various people in our company
4
3998
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 page request? - will each reading of a session variable cause a round trip to the DB server? or does the complete session live within the HttpContext object? - when asp.net session state is enabled (in any mode), after a session has been created,...
5
1196
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 file to fail to work? I know that there's a bug that will cause it to happen if the application directory is more than 8 characters. It can also happen if there's a problem with the web.config file itself. What are some of the other...
2
1485
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 "System.Runtime.InteropServices.SEHException:External component has thrown an exception". I debugged the unmanaged C++ code & found that the code that generated this exception is CDaoDatabase db; db.open("C:\\VM.mdb") // this is the code that generated exception
1
2262
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
8680
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9030
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7738
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 project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2335
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.