Solved

Read APP.Configu

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Vb.net progressbar with timer1 in visual studio win app 11 51
Need help with a query 14 55
vb.net code 9 29
VB.NET : Selection Out of Range Parameter Name : Value 22 37
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

710 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