Link to home
Start Free TrialLog in
Avatar of jindalee
jindalee

asked on

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
Avatar of kaufmed
kaufmed
Flag of United States of America image

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.
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.
Avatar of jindalee
jindalee

ASKER

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)"}
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.
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>
The only config file I have is the one I posted in the snippet
Here's my Settings in the attached image
SQL2.gif
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?


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
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?
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
ASKER CERTIFIED SOLUTION
Avatar of Alfred A.
Alfred A.
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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?
kaufmed:
config file settings in debug and release are identical.
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.