title: WPF and ADO.NET EF - error part II
body: <p>I have added the connection string to the App.config of a main executable in my wpr, prism application and I get the following error:</p>
  
  <pre><code>System.TypeInitializationException was unhandled
    Message=The type initializer for 'Microsoft.Practices.EnterpriseLibrary.Logging.Logger' threw an exception.
    Source=Microsoft.Practices.EnterpriseLibrary.Logging
    TypeName=Microsoft.Practices.EnterpriseLibrary.Logging.Logger
    StackTrace:
         at Microsoft.Practices.EnterpriseLibrary.Logging.Logger.get_Writer()
         at Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(Object message, ICollection`1 categories, Int32 priority, Int32 eventId, TraceEventType severity, String title, IDictionary`2 properties)
         at Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(Object message, String category, Int32 priority)
         at StockTraderRI.EnterpriseLibraryLoggerAdapter.Log(String message, Category category, Priority priority) in &lt;my application&gt;\EnterpriseLibraryLoggerAdapter.cs:line 28
         at Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper.Run(Boolean runWithDefaultConfiguration) in &lt;my application&gt;\CAL\Desktop\Composite.UnityExtensions\UnityBootstrapper.cs:line 85
         at Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper.Run() in &lt;my application&gt;\CAL\Desktop\Composite.UnityExtensions\UnityBootstrapper.cs:line 69
         at StockTraderRI.App.RunInDebugMode() in &lt;my application&gt;\app.xaml.cs:line 44
         at StockTraderRI.App.OnStartup(StartupEventArgs e) in &lt;my application&gt;\app.xaml.cs:line 34
         at System.Windows.Application.&lt;.ctor&gt;b__1(Object unused)
         at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
         at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
         at System.Windows.Threading.DispatcherOperation.InvokeImpl()
         at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
         at System.Threading.ExecutionContext.runTryCode(Object userData)
         at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
         at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
         at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
         at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
         at System.Windows.Threading.DispatcherOperation.Invoke()
         at System.Windows.Threading.Dispatcher.ProcessQueue()
         at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean&amp; handled)
         at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean&amp; handled)
         at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
         at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
         at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
         at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
         at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
         at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG&amp; msg)
         at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
         at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
         at System.Windows.Threading.Dispatcher.Run()
         at System.Windows.Application.RunDispatcher(Object ignore)
         at System.Windows.Application.RunInternal(Window window)
         at System.Windows.Application.Run(Window window)
         at System.Windows.Application.Run()
         at StockTraderRI.App.Main() in &lt;my application&gt;\obj\Debug\App.g.cs:line 0
    InnerException: System.Configuration.ConfigurationErrorsException
         Message=Configuration system failed to initialize
         Source=System.Configuration
         BareMessage=Configuration system failed to initialize
         Line=0
         StackTrace:
         InnerException: System.Configuration.ConfigurationErrorsException
              Message=Only one &lt;configSections&gt; element allowed per config file and if present must be the first child of the root &lt;configuration&gt; element. (&lt;my application&gt;\bin\Debug\StockTraderRI.exe.Config line 7)
              Source=System.Configuration
              BareMessage=Only one &lt;configSections&gt; element allowed per config file and if present must be the first child of the root &lt;configuration&gt; element.
              Filename=&lt;my application&gt;.exe.Config
              Line=7
              StackTrace:
                   at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
                   at System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)
                   at System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()
                   at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
  </code></pre>
  
  <p>My App.conf looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
    &lt;connectionStrings&gt;
      &lt;add name="DBEntities" connectionString="metadata=res://DataAccessLayer/EntityDataModel.csdl|res://DataAccessLayer/EntityDataModel.ssdl|res://DataAccessLayer/EntityDataModel.msl;provider=System.Data.SqlServerCe.3.5;provider connection string=&amp;quot;Data Source=|DataDirectory|\DB.sdf;Password=password;Persist Security Info=True&amp;quot;" providerName="System.Data.EntityClient" /&gt;
    &lt;/connectionStrings&gt;
  
    &lt;configSections&gt;
  
      &lt;section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/&gt;
      &lt;section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/&gt;
      &lt;section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/&gt;
    &lt;/configSections&gt;
  </code></pre>
  
  <p>Does anyone have any idea what is wrong? Thanks for reading.</p>