473,320 Members | 2,012 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,320 software developers and data experts.

Problems accessing configuration file in .NET 2.0

I am using Visual Studio 2005, creating a VB.NET program. I am have created
a settings file and two settings in the file. The section that it created
in my app.config is below. I can not figure out how to access the two
settings. I need to be able to get the data out of the settings. And update
them at a later point as well. I have tried all sorts of things.
Dim CurReceipt As Integer =
CInt(ConfigurationManager.AppSettings("ReceiptNumb er"))

Dim CurTrans As Int64 =
CLng(ConfigurationManager.AppSettings("Transaction NUmber"))

Each of the above lines just return 0. According to the help file, i
should be able to use My.Settings.ReceiptNumber - but that is not
available. Any ideas? Thanks
Stacey

<applicationSettings>

<GiftGards.Cards>

<setting name="ReceiptNumber" serializeAs="String">

<value>50</value>

</setting>

<setting name="TransactionNumber" serializeAs="String">

<value>1000</value>

</setting>

</GiftGards.Cards>

</applicationSettings>

-----------WARNINGS AND ERROR MESSAGES BELOW-------------
Warning 1 The 'requirePermission' attribute is not declared. D:\Projects
..NET\RTCGiftGards\RTCGiftGards\app.config 5 176 RTCGiftGards
Message 2 Could not find schema information for the element
'applicationSettings'. D:\Projects .NET\RTCGiftGards\RTCGiftGards\app.config
30 6 RTCGiftGards
Message 3 Could not find schema information for the element
'RTCGiftGards.RTCCards'. D:\Projects
..NET\RTCGiftGards\RTCGiftGards\app.config 31 10 RTCGiftGards
Message 4 Could not find schema information for the element 'setting'.
D:\Projects .NET\RTCGiftGards\RTCGiftGards\app.config 32 14 RTCGiftGards
Message 5 Could not find schema information for the attribute 'name'.
D:\Projects .NET\RTCGiftGards\RTCGiftGards\app.config 32 22 RTCGiftGards
Message 6 Could not find schema information for the attribute 'serializeAs'.
D:\Projects .NET\RTCGiftGards\RTCGiftGards\app.config 32 43 RTCGiftGards
Message 7 Could not find schema information for the element 'value'.
D:\Projects .NET\RTCGiftGards\RTCGiftGards\app.config 33 18 RTCGiftGards
Message 8 Could not find schema information for the element 'setting'.
D:\Projects .NET\RTCGiftGards\RTCGiftGards\app.config 35 14 RTCGiftGards
Message 9 Could not find schema information for the attribute 'name'.
D:\Projects .NET\RTCGiftGards\RTCGiftGards\app.config 35 22 RTCGiftGards
Message 10 Could not find schema information for the attribute
'serializeAs'. D:\Projects .NET\RTCGiftGards\RTCGiftGards\app.config 35 47
RTCGiftGards
Message 11 Could not find schema information for the element 'value'.
D:\Projects .NET\RTCGiftGards\RTCGiftGards\app.config 36 18 RTCGiftGards
Dec 1 '05 #1
9 13233
Hi Stacey ... I've just been working on something similar myself.

The upshot is that your settings cannot be written to the app.config file,
since it is read-only at run-time. Instead, you should use the user.config
file ... have a look at this -
http://msdn.microsoft.com/library/en...asp?frame=true

"Stacey" <St*****@community.nospam> wrote in message
news:uE**************@TK2MSFTNGP15.phx.gbl...
I am using Visual Studio 2005, creating a VB.NET program. I am have created
a settings file and two settings in the file. The section that it created
in my app.config is below. I can not figure out how to access the two
settings. I need to be able to get the data out of the settings. And
update them at a later point as well. I have tried all sorts of things.
Dim CurReceipt As Integer =
CInt(ConfigurationManager.AppSettings("ReceiptNumb er"))

Dim CurTrans As Int64 =
CLng(ConfigurationManager.AppSettings("Transaction NUmber"))

Each of the above lines just return 0. According to the help file, i
should be able to use My.Settings.ReceiptNumber - but that is not
available. Any ideas? Thanks
Stacey

<applicationSettings>

<GiftGards.Cards>

<setting name="ReceiptNumber" serializeAs="String">

<value>50</value>

</setting>

<setting name="TransactionNumber" serializeAs="String">

<value>1000</value>

</setting>

</GiftGards.Cards>

</applicationSettings>

-----------WARNINGS AND ERROR MESSAGES BELOW-------------
Warning 1 The 'requirePermission' attribute is not declared. D:\Projects
.NET\RTCGiftGards\RTCGiftGards\app.config 5 176 RTCGiftGards
Message 2 Could not find schema information for the element
'applicationSettings'. D:\Projects
.NET\RTCGiftGards\RTCGiftGards\app.config 30 6 RTCGiftGards
Message 3 Could not find schema information for the element
'RTCGiftGards.RTCCards'. D:\Projects
.NET\RTCGiftGards\RTCGiftGards\app.config 31 10 RTCGiftGards
Message 4 Could not find schema information for the element 'setting'.
D:\Projects .NET\RTCGiftGards\RTCGiftGards\app.config 32 14 RTCGiftGards
Message 5 Could not find schema information for the attribute 'name'.
D:\Projects .NET\RTCGiftGards\RTCGiftGards\app.config 32 22 RTCGiftGards
Message 6 Could not find schema information for the attribute
'serializeAs'. D:\Projects .NET\RTCGiftGards\RTCGiftGards\app.config 32 43
RTCGiftGards
Message 7 Could not find schema information for the element 'value'.
D:\Projects .NET\RTCGiftGards\RTCGiftGards\app.config 33 18 RTCGiftGards
Message 8 Could not find schema information for the element 'setting'.
D:\Projects .NET\RTCGiftGards\RTCGiftGards\app.config 35 14 RTCGiftGards
Message 9 Could not find schema information for the attribute 'name'.
D:\Projects .NET\RTCGiftGards\RTCGiftGards\app.config 35 22 RTCGiftGards
Message 10 Could not find schema information for the attribute
'serializeAs'. D:\Projects .NET\RTCGiftGards\RTCGiftGards\app.config 35 47
RTCGiftGards
Message 11 Could not find schema information for the element 'value'.
D:\Projects .NET\RTCGiftGards\RTCGiftGards\app.config 36 18 RTCGiftGards

Dec 1 '05 #2
Unless I am missing things, I am doing it that way. I told it to create a
new settings file. and it does.. but it also writes the entires into the
app.config. The file it creates is called RTCCards.settings and it has my
two values in it.

"Andrew Kidd" <an****@nospam.com> wrote in message
news:Oe**************@TK2MSFTNGP10.phx.gbl...
Hi Stacey ... I've just been working on something similar myself.

The upshot is that your settings cannot be written to the app.config file,
since it is read-only at run-time. Instead, you should use the user.config
file ... have a look at this -
http://msdn.microsoft.com/library/en...asp?frame=true

"Stacey" <St*****@community.nospam> wrote in message
news:uE**************@TK2MSFTNGP15.phx.gbl...
I am using Visual Studio 2005, creating a VB.NET program. I am have
created a settings file and two settings in the file. The section that it
created in my app.config is below. I can not figure out how to access the
two settings. I need to be able to get the data out of the settings. And
update them at a later point as well. I have tried all sorts of things.
Dim CurReceipt As Integer =
CInt(ConfigurationManager.AppSettings("ReceiptNumb er"))

Dim CurTrans As Int64 =
CLng(ConfigurationManager.AppSettings("Transaction NUmber"))

Each of the above lines just return 0. According to the help file, i
should be able to use My.Settings.ReceiptNumber - but that is not
available. Any ideas? Thanks
Stacey

<applicationSettings>

<GiftGards.Cards>

<setting name="ReceiptNumber" serializeAs="String">

<value>50</value>

</setting>

<setting name="TransactionNumber" serializeAs="String">

<value>1000</value>

</setting>

</GiftGards.Cards>

</applicationSettings>

-----------WARNINGS AND ERROR MESSAGES BELOW-------------
Warning 1 The 'requirePermission' attribute is not declared. D:\Projects
.NET\RTCGiftGards\RTCGiftGards\app.config 5 176 RTCGiftGards
Message 2 Could not find schema information for the element
'applicationSettings'. D:\Projects
.NET\RTCGiftGards\RTCGiftGards\app.config 30 6 RTCGiftGards
Message 3 Could not find schema information for the element
'RTCGiftGards.RTCCards'. D:\Projects
.NET\RTCGiftGards\RTCGiftGards\app.config 31 10 RTCGiftGards
Message 4 Could not find schema information for the element 'setting'.
D:\Projects .NET\RTCGiftGards\RTCGiftGards\app.config 32 14 RTCGiftGards
Message 5 Could not find schema information for the attribute 'name'.
D:\Projects .NET\RTCGiftGards\RTCGiftGards\app.config 32 22 RTCGiftGards
Message 6 Could not find schema information for the attribute
'serializeAs'. D:\Projects .NET\RTCGiftGards\RTCGiftGards\app.config 32
43 RTCGiftGards
Message 7 Could not find schema information for the element 'value'.
D:\Projects .NET\RTCGiftGards\RTCGiftGards\app.config 33 18 RTCGiftGards
Message 8 Could not find schema information for the element 'setting'.
D:\Projects .NET\RTCGiftGards\RTCGiftGards\app.config 35 14 RTCGiftGards
Message 9 Could not find schema information for the attribute 'name'.
D:\Projects .NET\RTCGiftGards\RTCGiftGards\app.config 35 22 RTCGiftGards
Message 10 Could not find schema information for the attribute
'serializeAs'. D:\Projects .NET\RTCGiftGards\RTCGiftGards\app.config 35
47 RTCGiftGards
Message 11 Could not find schema information for the element 'value'.
D:\Projects .NET\RTCGiftGards\RTCGiftGards\app.config 36 18 RTCGiftGards


Dec 1 '05 #3
well to save yourselves a lot of trouble

use Francesco`s class ,,, VB.Net and C# version availlable
http://www.vb2themax.com/ShowContent...a-04c861fac4a5

I use this class in 2003 and 2005

regards

Michel Posseth [MCP]
"Stacey" <St*****@community.nospam> schreef in bericht
news:eK**************@TK2MSFTNGP14.phx.gbl...
Unless I am missing things, I am doing it that way. I told it to create a
new settings file. and it does.. but it also writes the entires into the
app.config. The file it creates is called RTCCards.settings and it has my
two values in it.

"Andrew Kidd" <an****@nospam.com> wrote in message
news:Oe**************@TK2MSFTNGP10.phx.gbl...
Hi Stacey ... I've just been working on something similar myself.

The upshot is that your settings cannot be written to the app.config
file, since it is read-only at run-time. Instead, you should use the
user.config file ... have a look at this -
http://msdn.microsoft.com/library/en...asp?frame=true

"Stacey" <St*****@community.nospam> wrote in message
news:uE**************@TK2MSFTNGP15.phx.gbl...
I am using Visual Studio 2005, creating a VB.NET program. I am have
created a settings file and two settings in the file. The section that
it created in my app.config is below. I can not figure out how to access
the two settings. I need to be able to get the data out of the settings.
And update them at a later point as well. I have tried all sorts of
things.
Dim CurReceipt As Integer =
CInt(ConfigurationManager.AppSettings("ReceiptNumb er"))

Dim CurTrans As Int64 =
CLng(ConfigurationManager.AppSettings("Transaction NUmber"))

Each of the above lines just return 0. According to the help file, i
should be able to use My.Settings.ReceiptNumber - but that is not
available. Any ideas? Thanks
Stacey

<applicationSettings>

<GiftGards.Cards>

<setting name="ReceiptNumber" serializeAs="String">

<value>50</value>

</setting>

<setting name="TransactionNumber" serializeAs="String">

<value>1000</value>

</setting>

</GiftGards.Cards>

</applicationSettings>

-----------WARNINGS AND ERROR MESSAGES BELOW-------------
Warning 1 The 'requirePermission' attribute is not declared. D:\Projects
.NET\RTCGiftGards\RTCGiftGards\app.config 5 176 RTCGiftGards
Message 2 Could not find schema information for the element
'applicationSettings'. D:\Projects
.NET\RTCGiftGards\RTCGiftGards\app.config 30 6 RTCGiftGards
Message 3 Could not find schema information for the element
'RTCGiftGards.RTCCards'. D:\Projects
.NET\RTCGiftGards\RTCGiftGards\app.config 31 10 RTCGiftGards
Message 4 Could not find schema information for the element 'setting'.
D:\Projects .NET\RTCGiftGards\RTCGiftGards\app.config 32 14 RTCGiftGards
Message 5 Could not find schema information for the attribute 'name'.
D:\Projects .NET\RTCGiftGards\RTCGiftGards\app.config 32 22 RTCGiftGards
Message 6 Could not find schema information for the attribute
'serializeAs'. D:\Projects .NET\RTCGiftGards\RTCGiftGards\app.config 32
43 RTCGiftGards
Message 7 Could not find schema information for the element 'value'.
D:\Projects .NET\RTCGiftGards\RTCGiftGards\app.config 33 18 RTCGiftGards
Message 8 Could not find schema information for the element 'setting'.
D:\Projects .NET\RTCGiftGards\RTCGiftGards\app.config 35 14 RTCGiftGards
Message 9 Could not find schema information for the attribute 'name'.
D:\Projects .NET\RTCGiftGards\RTCGiftGards\app.config 35 22 RTCGiftGards
Message 10 Could not find schema information for the attribute
'serializeAs'. D:\Projects .NET\RTCGiftGards\RTCGiftGards\app.config 35
47 RTCGiftGards
Message 11 Could not find schema information for the element 'value'.
D:\Projects .NET\RTCGiftGards\RTCGiftGards\app.config 36 18 RTCGiftGards



Dec 1 '05 #4
Hi StaceyL,

Thanks for your post.

Can you show us how you added the settings in app.config? Do you use the
Settings.settings designer?

Normally, after we adding the setting in the designer, we should can refer
the item with My.Settings.[item name] in VB.net code file.

If you failed to do this, can you provide some detailed steps to reproduce
your problem?

Below is the official document for manipulating the application settings in
VS2005:
"Accessing Application Settings "
http://msdn2.microsoft.com/en-us/library/bc6ws923.aspx
"Managing Application Settings"
http://msdn2.microsoft.com/en-us/library/c9db58th.aspx

Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Dec 2 '05 #5
I added the strings using the designer. Ie.. right click on the solution.
Add --> New --> Settings file. Enter my two settings into the settings file.
They are not accessible.

""Jeffrey Tan[MSFT]"" <v-*****@online.microsoft.com> wrote in message
news:FD**************@TK2MSFTNGXA02.phx.gbl...
Hi StaceyL,

Thanks for your post.

Can you show us how you added the settings in app.config? Do you use the
Settings.settings designer?

Normally, after we adding the setting in the designer, we should can refer
the item with My.Settings.[item name] in VB.net code file.

If you failed to do this, can you provide some detailed steps to reproduce
your problem?

Below is the official document for manipulating the application settings
in
VS2005:
"Accessing Application Settings "
http://msdn2.microsoft.com/en-us/library/bc6ws923.aspx
"Managing Application Settings"
http://msdn2.microsoft.com/en-us/library/c9db58th.aspx

Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Dec 2 '05 #6
Additionally, you can download a small sample project that shows the
problem.

http://www.levineclan.net/SettingsTester.zip
""Jeffrey Tan[MSFT]"" <v-*****@online.microsoft.com> wrote in message
news:FD**************@TK2MSFTNGXA02.phx.gbl...
Hi StaceyL,

Thanks for your post.

Can you show us how you added the settings in app.config? Do you use the
Settings.settings designer?

Normally, after we adding the setting in the designer, we should can refer
the item with My.Settings.[item name] in VB.net code file.

If you failed to do this, can you provide some detailed steps to reproduce
your problem?

Below is the official document for manipulating the application settings
in
VS2005:
"Accessing Application Settings "
http://msdn2.microsoft.com/en-us/library/bc6ws923.aspx
"Managing Application Settings"
http://msdn2.microsoft.com/en-us/library/c9db58th.aspx

Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Dec 3 '05 #7
Hi Stacey,

Thanks for your feedback.

No, we should not add a new Settings.settings file. We should use the
default Settings.settings file to store the application/user config data.
Then VB.net20005 designer will associate them in My.Settings class.

To use the default Settings.settings file, we can right click Project node
in the solution explorer, then choose the "Properties" to open the "Project
Properties" tab. Then we can click "Settings" tab in the "Project
Properties" tab. At last, we can set the config data in the designer.

After this, we should can use it in the code file.

Hope this helps

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Dec 6 '05 #8
That did it.. thanks.
""Jeffrey Tan[MSFT]"" <v-*****@online.microsoft.com> wrote in message
news:6q****************@TK2MSFTNGXA02.phx.gbl...
Hi Stacey,

Thanks for your feedback.

No, we should not add a new Settings.settings file. We should use the
default Settings.settings file to store the application/user config data.
Then VB.net20005 designer will associate them in My.Settings class.

To use the default Settings.settings file, we can right click Project node
in the solution explorer, then choose the "Properties" to open the
"Project
Properties" tab. Then we can click "Settings" tab in the "Project
Properties" tab. At last, we can set the config data in the designer.

After this, we should can use it in the code file.

Hope this helps

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Dec 6 '05 #9
You are welcome

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Dec 7 '05 #10

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

Similar topics

6
by: Serge calderara | last post by:
Dear all, Does any one have a ready class that is able to access a configuration file and make different type of querry, read, write operation? Why re invanting the real if something already...
5
by: Tyler Style | last post by:
Hullo - looking for a little advice here. I have a form on a page in one domain submitting to a cgi in another domain. Weirdly, on some Windows XP systems, a form on the page fails to submit/post...
2
by: wan2tri | last post by:
hello, good day to all of you, hi, im am new in .net , how can i access two or more object remotely , because currently im only accessing one object, windows services is the host, i have a...
0
by: Joergen Bech | last post by:
Fairly new to ASP.NET 1.1. Getting the error below when running application on a web server outside of my control, but only the first time I run it: 1. After a long period of inactivity (or...
4
by: James | last post by:
I have a VB windows forms application that accesses a Microsoft Access database that has been secured using user-level security. The application is being deployed using No-Touch deployment. The...
4
by: Kaush | last post by:
Hi all, I am creating a webservice to accept SOAP messages, parse the message and send a SOAP response back to the client accessing my web service using WSE-2 in ASP.NET. I am creating a class...
1
by: muthu | last post by:
Hi guys, Iam using dot framework 2.0.vs.net2005.I created a class library project and added a class file.And also i added a app.config file.And i declared a connection string in that config...
3
by: Newbie | last post by:
Hi All Trying to create a mini-ASP web dev with a couple of PCs at school. When the teachers are happy with the site on the LAN then going to upload it to the school site. Problem is having...
16
by: sunil | last post by:
Hi, I have a service written in c# that I need to run as a "Network Service". I am using a setup project to install the service. If I install the service in User's Personal Folder, I get the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.