Configuration Errors Exception question

In my database app, if I run it in debug mode, it throws a Configuration Errors Exception. If I run in release mode it doesn't and the app works exactly as I expect it to run.

Help suggests something wrong with the app.config file but I cannot see anything wrong with it. Nor can I recall anything I have done to change it.

I've attached the app.config file and would appreciate some advice on how to resolve the issue.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
    </configSections>
    <connectionStrings>
        <add name="CMS.My.MySettings.CMSConnectionString" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=CMS;Persist Security Info=True;User ID=sa;Password=xxxxxxxx;Pooling=False"
            providerName="System.Data.SqlClient" />
    </connectionStrings>
    <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>
</configuration>

Open in new window

ExceptionError.gif
LVL 1
jindaleeAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
If you click the "View Detail" link, there may be more information inside of "Inner Exception" that may give you a hint as to what's wrong.
Alfred A.Commented:
Hi,

Try the following:

Select your app.config in the Solution Explorer.  Then, set the app.config File Properties "Copy To Output Directory" to "Copy always" in the dropdown box.

And then, test it out.

I hope this helps.
jindaleeAuthor Commented:
Alfred1: No joy.

kaufmed:
Inner Exception = "Unrecognized configuration section userSettings. (C:\Users\Soulmates\AppData\Local\Secrett_Systems\CMS.vshost.exe_StrongName_gbau12ajyk3ofpospkzs5052uor0fkue\5.1.0.0\user.config line 3)"}
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

Alfred A.Commented:
From the error,

Do you use userSettings?  I don't see it in the code snippet.

Check your Project Properties.  Right-Click Project -> go to Properties -> select Settings.

Something is wrong in there based on the error.
Alfred A.Commented:
Also, do you have any other .config files?  Do you have something like this in your .config files?  This is under <configuration>

<userSettings>
    <WindowsApplication1.My.MySettings>
      <setting name="Setting" serializeAs="String">
        <value>test</value>
      </setting>
    </WindowsApplication1.My.MySettings>
  </userSettings>
jindaleeAuthor Commented:
The only config file I have is the one I posted in the snippet
jindaleeAuthor Commented:
Here's my Settings in the attached image
SQL2.gif
Alfred A.Commented:
OK.  This would be a bit silly.  Can you try doing a rebuild and then run it?  If it still doesn't work, Can you do a clean solution, rebuild and run again?

If it still doesn't work, remove obj folder and bin/debug, bin/release through windows explorer, and then build or rebuild your solution afterwards?


jindaleeAuthor Commented:
OK. No change when I:
1. Rebuild and run.
2. Clean, rebuild, run
3. Remove obj and bin folders through Windows Explorer, clean, rebuild and run.

I'm going to try building a dummy solution - 1 form - to see if it's systemic or application related
Alfred A.Commented:
OK.  That was my ace in most cases with .NET issues.  :-)

OK.  Now, what if you remove that user string in the properties for testing purposes and run it.

Also, what if remove the user string and just copy the connection string "manually" in the app.config and run it?
jindaleeAuthor Commented:
It's definitely application related!

I'm not very far down the path of development on this one so I might just start from scratch
Alfred A.Commented:
Hi,

I actually tried setting a test project on my own here as I am very, very curious of this one.

And the result, everything worked fine!

Yes.  Start from scratch.  This is just weird.  It is possible that there might be corrupt objects or files in there.  Do you use Sourcesafe or TFS?  SourceSafe sometimes tend to be have corrupt files or objects in a sourcesafe db with heavy use after around three years or more from experience.  

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
käµfm³d 👽Commented:
Can you check the debug and release folders and confirm that both folders have exactly the same config file settings in their respective config files?
jindaleeAuthor Commented:
kaufmed:
config file settings in debug and release are identical.
jindaleeAuthor Commented:
I do use Sourcesafe. I took copies of the source files from the project directory, created a new project with Sourcesafe turned off and added the source files to the new project. Compiled and runs as expected in both debug and release mode. Looks like you were right in suggesting some corruption in the Sourcesafe db.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.