Solved

Read APP.Configu

Posted on 2013-01-03
2
255 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
2 Comments
 
LVL 8

Expert Comment

by:5teveo
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Zoom web page in asp.net 2 34
How to trouble shoot .net contact form 3 30
GridDataView 6 44
Crystal Report for VS2013 17 35
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…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now