Solved

Read APP.Configu

Posted on 2013-01-03
2
262 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 500 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

627 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