473,387 Members | 1,812 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,387 software developers and data experts.

configuration variable access

hi
i want to access value of a variable in app.config

my config file looks like
Expand|Select|Wrap|Line Numbers
  1. <configuration>
  2.   <applicationSettings>
  3.     <wpf1.Properties.Settings>
  4.       <setting name="ThreadDelay" serializeAs="String ">
  5.         <value>5000</value>
  6.       </setting>
  7.     </wpf1.Properties.Settings>
  8.   </applicationSettings>
  9. </configuration>
and in code behind

Expand|Select|Wrap|Line Numbers
  1. string delay = System.Configuration.ConfigurationSettings.AppSettings["ThreadDelay"].ToString();

but it comes with an error that object reference not set to an instance of object

my .config filename was wpf1.config as i rename it to app.config it start working fine
any suggesstions
Apr 12 '10 #1
3 2263
tlhintoq
3,525 Expert 2GB
TIP: When you first created your question you were asked to wrap your code with [code] tags.

It really does help a bunch. Look how much easier it is to read now that someone has done it for you. Its the button with a '#' on it. More on tags. They're cool. Check'em out.
Apr 12 '10 #2
tlhintoq
3,525 Expert 2GB
"How do I fix a 'object reference not set to an instance of an object' error?
The line your code stopped on while debugging holds all your answers.
One of the variables/objects was created but not initialized. For example:
Expand|Select|Wrap|Line Numbers
  1. string TempString;// Created but not initialized so this is still null
  2. //versus
  3. string TempString = string.empty;
Debug your project again. This time, when it breaks on a line look at the Locals pallet to see which variable/object is null. You can also hover your mouse over each variable and the hothelp will shows its value. One of them will be null.

my .config filename was wpf1.config as i rename it to app.config it start working fine
any suggesstions
Since renaming the file has solved the problem... what do you need suggestions for?
Apr 12 '10 #3
What it sounds like to me is that you need your config file to be named as your executablename.exe.config. That is how my config files are named after compilation. Just a thought.
Apr 19 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: serge calderara | last post by:
dear all, I have problem accessing section group in my configuration application file. I got an error saying thta I can have only one section ???? here is my application configuration looks...
3
by: vineetbatta | last post by:
Hi all, What is the best way to store the configuration varaibles of the application (E.g: Registry, Web Config file, Xml file , text file etc)? E.g: of configuration variable is ...
1
by: Manu | last post by:
I would like to gather data from the user in the startup phase. Then to create a Configuration variable from which connection objects will read their connection string. (Dynamic binding) How can I...
6
by: chokk | last post by:
All, I am getting the following error when I try to run a form page. Can someone tell me what this is about and show me how to fix it. Thnaks. Server Error in '/' Application...
2
by: Terry Holland | last post by:
I posted a follow up to an earlier post but did not receive response so here it is again (with original post and response) > This could be because you are running the index service over this web...
10
by: Rider | last post by:
Hi, simple(?) question about asp.net configuration.. I've installed ASP.NET 2.0 QuickStart Sample successfully. But, When I'm first start application the follow message shown. ========= Server...
5
by: Hardy Wang | last post by:
Hi all, I understand, in .Net 2.0 we have little bit different model to read config file from .Net 1.1. Basically I need to use WebConfigurationManager.AppSettings to read from web.config, and...
5
by: Jay | last post by:
I want to store various text settings in a configuration file, that I will read into C# and make use of. Here's a simplified example of the file: #comment loop(var=1:5){ deviceundertest ...
8
by: Alberto | last post by:
Can you tell me how to read and modify a value in the app.config file using this class? Thank you very much
3
by: Mike | last post by:
Hi I have problem as folow: Caught Exception: System.Configuration.ConfigurationErrorsException: An error occurred loading a configuration file: Request for the permission of type...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...

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.