0

I'm trying to get my app to read a variable I created in the app.config file for my VB project, and am experiencing two errors. Developing this in VS Community (up to date and using latest .Net framework).

  1. When I click a form button that triggers code to read a variable from the app.config file. I receive this error:

link to error1.jpg

The button triggers this code: Dim strKey As String strKey = My.Settings.TestKey

  1. When I open/close the app.config file I see the error "An error occurred while reading the app.config file. The file might be corrupted or contain invalid XML". I've run the XML through an online checker and it passed. I'll pasted the app.config XML at the bottom.

The app.config file was generated automatically, and the TestKey variable was added to it via the project properties page, so I haven't amended the app.config file manually at all.

Any suggestions gratefully received.

Cheers,

Jay

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System.Configuration.ConfigurationManager, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" >
            <section name="Doghunter.My.MySettings" type="System.Configuration.ClientSettingsSection, System.Configuration.ConfigurationManager, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" requirePermission="false" />
        </sectionGroup>
    </configSections>
    <system.diagnostics>
        <sources>
            <!-- This section defines the logging configuration for My.Application.Log -->
            <source name="DefaultSource" switchName="DefaultSwitch">
                <listeners>
                    <add name="FileLog"/>
                    <!-- Uncomment the below section to write to the Application Event Log -->
                    <!--<add name="EventLog"/>-->
                </listeners>
            </source>
        </sources>
        <switches>
            <add name="DefaultSwitch" value="Information" />
        </switches>
        <sharedListeners>
            <add name="FileLog"
                 type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
                 initializeData="FileLogWriter"/>
            <!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
            <!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->
        </sharedListeners>
    </system.diagnostics>
    <applicationSettings>
        <Doghunter.My.MySettings>
            <setting name="TestKey" serializeAs="String">
                <value>Zebedee</value>
            </setting>
        </Doghunter.My.MySettings>
    </applicationSettings>
</configuration>
DemBones
  • 1
  • 1

0 Answers0