CONFIG files in VStudio 2003 
Author Message
 CONFIG files in VStudio 2003

I am writing an app that needs a little bit of user configuration info on
startup. I the old days, this would have called for an INI file, and with
.Net, I decided to use the appSettings section of the config file. This
worked fine in the old VStudio, but the new one deletes my config file when
I start my app, every time. It seems to want the file for it's exclusive
use, to store dynamic configuration settings.

Am I doing this incorrectly? Should I use some other mechanism? Should I
create my own homegrown XML file to store this stuff in?

Any help would be appreciated!!

- Dave Allen



Tue, 25 Oct 2005 06:25:34 GMT  
 CONFIG files in VStudio 2003
Hi Dave,

You may want to name the configure file as app.config. Then, add it to the
project. VS .NET will copy the app.config to the bin folder automation with
the appropriate name. Please check following article for more information:

313405 HOW TO: Store and Retrieve Custom Information from an Application
http://support.microsoft.com/?id=313405

Best Regards,
Leo Chen

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------

| Subject: CONFIG files in VStudio 2003
| Date: Thu, 8 May 2003 16:25:34 -0600
| Lines: 15
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.3790.0
| X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.3790.0

| Newsgroups: microsoft.public.dotnet.languages.vb
| NNTP-Posting-Host: net100-fw-gw.carrieraccess.com 65.221.135.250
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:106676
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
|
| I am writing an app that needs a little bit of user configuration info on
| startup. I the old days, this would have called for an INI file, and with
| .Net, I decided to use the appSettings section of the config file. This
| worked fine in the old VStudio, but the new one deletes my config file
when
| I start my app, every time. It seems to want the file for it's exclusive
| use, to store dynamic configuration settings.
|
| Am I doing this incorrectly? Should I use some other mechanism? Should I
| create my own homegrown XML file to store this stuff in?
|
| Any help would be appreciated!!
|
| - Dave Allen
|
|
|



Tue, 25 Oct 2005 12:13:44 GMT  
 CONFIG files in VStudio 2003
Thanks for replying so quickly Leo. I tried the approach described already,
and it didn't work. Let me give you the whole story...

I began this application in VB .Net 2002, and everything was working fine
with the config file along with the EXE in both the debug and release
directories. It was called FrontOfficeMgr.exe.config, and I have included it
below:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
 <appSettings>
  <add key="Locale" value="es-MX" />
  <add key="LogLevel" value="High" />
  <add key="DbServer" value="CADEVSLXSQL" />
  <add key="DbUser" value="0AF56A64538FDECB03113CD72B97AD5A" />
  <add key="DbPassword" value="6B175C361CBE7E88A2000FE830BC2901" />
 </appSettings>
</configuration>

Here is the code that read the config file:

    Private Sub ReadAppSettings()
        Dim m_retval As Boolean = True
        Dim m_strLogLevel As String
        Dim m_strCon As String
        Dim m_strLocale As String

        '
        ' 1. Logging Level
        '
        m_strLogLevel =
Configuration.ConfigurationSettings.AppSettings("Loglevel")
        If m_strLogLevel = Nothing Then
            Throw New ApplicationException("Bad Configuration File. Missing
Logging Level!")
        Else
            Select Case UCase(m_strLogLevel)
                Case "NONE" : G_loglvl =
ExceptionEnums.CGateLoggingLevel.None
                Case "LOW" : G_loglvl = ExceptionEnums.CGateLoggingLevel.Low
                Case "MEDIUM" : G_loglvl =
ExceptionEnums.CGateLoggingLevel.Medium
                Case "HIGH" : G_loglvl =
ExceptionEnums.CGateLoggingLevel.High
                Case Else : G_loglvl =
ExceptionEnums.CGateLoggingLevel.Medium
            End Select
        End If

As soon as I opened my project in VB .Net 2003, my code for retrieving these
settings generated a runtime error with the first setting, and said that it
couldn't deal with a NULL value for "Locale". In reading the documentation,
I noticed that there was a new method developed for dealing with app config
files, in the framework called AppSettingsReader. I figured that was the
problem and reworked my code. Here's the new version:

    Private Sub ReadAppSettings()
        Dim m_retval As Boolean = True
        Dim m_strLogLevel As String
        Dim m_strCon As String
        Dim m_strLocale As String
        Dim rdr As New Configuration.AppSettingsReader

        '
        ' 1. Logging Level
        '
        m_strLogLevel = CType(rdr.GetValue("Loglevel",
GetType(System.String)), String)
        If m_strLogLevel = Nothing Then
            Throw New ApplicationException("Bad Configuration File. Missing
Logging Level!")
        Else
            Select Case UCase(m_strLogLevel)
                Case "NONE" : G_loglvl =
ExceptionEnums.CGateLoggingLevel.None
                Case "LOW" : G_loglvl = ExceptionEnums.CGateLoggingLevel.Low
                Case "MEDIUM" : G_loglvl =
ExceptionEnums.CGateLoggingLevel.Medium
                Case "HIGH" : G_loglvl =
ExceptionEnums.CGateLoggingLevel.High
                Case Else : G_loglvl =
ExceptionEnums.CGateLoggingLevel.Medium
            End Select
        End If

After that failed, I began experimenting with "Dynamic Configuration"
settings, which also plays in this config file. That feature took over the
config file completely, and wouldn't allow me to put anything of my own in.
I quickly disabled all dynamic configuration settings in my form, but the
app continues to put that info in the config file, and denies me the ability
to put my own information in it. If I delete the file from BIN, it puts it
back. I tried creating the file from scratch in the project, and it still
puts a different on in.

I am at a loss Leo...

- Dave Allen



Quote:
> Hi Dave,

> You may want to name the configure file as app.config. Then, add it to the
> project. VS .NET will copy the app.config to the bin folder automation
with
> the appropriate name. Please check following article for more information:

> 313405 HOW TO: Store and Retrieve Custom Information from an Application
> http://support.microsoft.com/?id=313405

> Best Regards,
> Leo Chen

> This posting is provided "AS IS" with no warranties, and confers no
rights.

> --------------------

> | Subject: CONFIG files in VStudio 2003
> | Date: Thu, 8 May 2003 16:25:34 -0600
> | Lines: 15
> | X-Priority: 3
> | X-MSMail-Priority: Normal
> | X-Newsreader: Microsoft Outlook Express 6.00.3790.0
> | X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.3790.0

> | Newsgroups: microsoft.public.dotnet.languages.vb
> | NNTP-Posting-Host: net100-fw-gw.carrieraccess.com 65.221.135.250
> | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
> | Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:106676
> | X-Tomcat-NG: microsoft.public.dotnet.languages.vb
> |
> | I am writing an app that needs a little bit of user configuration info
on
> | startup. I the old days, this would have called for an INI file, and
with
> | .Net, I decided to use the appSettings section of the config file. This
> | worked fine in the old VStudio, but the new one deletes my config file
> when
> | I start my app, every time. It seems to want the file for it's exclusive
> | use, to store dynamic configuration settings.
> |
> | Am I doing this incorrectly? Should I use some other mechanism? Should I
> | create my own homegrown XML file to store this stuff in?
> |
> | Any help would be appreciated!!
> |
> | - Dave Allen
> |
> |
> |



Wed, 26 Oct 2005 00:05:15 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Problem with config files in VB.NET 2003

2. Visual Studio .Net 2003 Final Beta, simple socket code breaks between 2002 and 2003

3. VB .Net 2003 Standard or VS .Net 2003 Pro for Smart Devices

4. Practice Files Missing in VB .NET 2003?

5. INI files with VB 2003.NET

6. Newbie: VB6 DSW Project file Won't Open Under DOTNET VStudio

7. how to read from xml config ex: web.config

8. VBA 97 to VBA 2K/2002/2003

9. Access 2003

10. outlook 2003 shut downs

11. Blank messages in Office XP Beta 2003

12. Problems with Microsoft Office Outlook 2003 Beta.

 

 
Powered by phpBB® Forum Software