Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Read APP.Configu

Posted on 2013-01-03
2
Medium Priority
?
263 Views
Last Modified: 2013-01-04
Hello

I have the fallown code to read some values from app.config file. When I execute it
I got nothing. What I have wrong. Please, let me now.

I use vb.net 2010.

Thanks you.


Imports System.Configuration

Public Class Form2

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim name As String = System.Configuration.ConfigurationManager.AppSettings("OperatorName")
        Console.WriteLine("Welcome " + name)

        Dim level As String = System.Configuration.ConfigurationManager.AppSettings("LoggerLevel")
        Console.WriteLine("Logger level: " + level)

    End Sub

End Class

The APP.config file has:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="OperatorName" value="Rita"></add>
    <add key="LoggerLevel" value="5"></add>
  </appSettings>
</configuration>
0
Comment
Question by:jsehernandez
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Expert Comment

by:5teveo
ID: 38742655
Try this syntax
Assign settings in project...
I assigned a setting named 'S4BackColor'

reference setting using
Me.Groupbox.backcolor = Global.<project name>.My.MySettings.Default.S4BackColor

If my project S4Backcolor variable was encoded as red then my groupbox would be red.
0
 
LVL 8

Accepted Solution

by:
PagodNaUtak earned 2000 total points
ID: 38742952
Are you sure that the config you are reading contains the value that you are expecting?

To verify, go to the bin > debug. Inside the debug folder you will see the config file.

Usually, the config file has a naming convention like <project name>.config,

Please let us know the result.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

664 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question