title: the type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception for Windows XP
body: <p>My WPF application works fine on Windows 7, but throws the above error when running on Windows XP.
  I am using ENtity Framework 6.1.1</p>
  
  <p>App.xaml is </p>
  
  <p></p>
  
  <pre><code>&lt;Application.Resources&gt;
      &lt;main:MainConverter x:Key="MainVerter"/&gt;
      &lt;Style x:Key="DetailHead1Style" TargetType="TextBlock"&gt;
          &lt;Setter Property="FontSize" Value="20"/&gt;
          &lt;Setter Property="FontWeight" Value="Bold"/&gt;
          &lt;Setter Property="Foreground" Value="DarkSlateGray"/&gt;
          &lt;Setter Property="Opacity" Value="0.8"/&gt;
          &lt;Setter Property="FontStyle" Value="Italic"/&gt;
          &lt;Setter Property="Margin" Value="6,2,6,2"/&gt;
      &lt;/Style&gt;
      &lt;Style  x:Key="DetailsOuterGridStyle" TargetType="Grid"&gt;
          &lt;Setter Property="Background" Value="White"/&gt;
      &lt;/Style&gt;
  &lt;/Application.Resources&gt;
  </code></pre>
  
  <p></p>
  
  <p>The inner exception is </p>
  
  <pre><code>System.Configuration.ConfigurationErrorsException: An error occurred creating the configuration section handler for entityFramework: Request failed. 
  (Q:\devnet10\SBD.CartBrowser\SBD.CartBrowser\bin\Debug\SBD.FlightControl.exe.Config line 23) ---&gt; System.Security.SecurityException: Request failed.
         at System.RuntimeMethodHandle.PerformSecurityCheck(Object obj, RuntimeMethodHandleInternal method, RuntimeType parent, UInt32 invocationFlags)
         at System.RuntimeMethodHandle.PerformSecurityCheck(Object obj, IRuntimeMethodInfo method, RuntimeType parent, UInt32 invocationFlags)
         at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
         at System.Reflection.ConstructorInfo.Invoke(Object[] parameters)
         at System.Configuration.TypeUtil.InvokeCtorWithReflectionPermission(ConstructorInfo ctor)
         at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSectionImpl(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
         at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSectionWithRestrictedPermissions(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
         at System.Configuration.RuntimeConfigurationRecord.CreateSection(Boolean inputIsTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
         at System.Configuration.BaseConfigurationRecord.CallCreateSection(Boolean inputIsTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader, String filename, Int32 line)
  </code></pre>
  
  <p>The app.config contains the correct connection string.  Could it be interpreted differently on XP?</p>
  
  <p>[Update]
  The code fails when initialising the connection.</p>
  
  <pre><code> var connect = new CartConnect(constr);
  </code></pre>
  
  <p>[Update]</p>
  
  <p>app.config is </p>
  
  <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;configuration&gt;
    &lt;configSections&gt;
      &lt;section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/&gt;
    &lt;/configSections&gt;
  
    &lt;connectionStrings&gt;
      &lt;add name="CartConnect_HAPPY4" connectionString="metadata=res://*/Edm.CartModel.csdl|res://*/Edm.CartModel.ssdl|res://*/Edm.CartModel.msl;provider=System.Data.SqlClient;provider connection string=&amp;quot;Database=mydatabase;Server=Server15\SQLExpress;Integrated Security=False;User=mylogin;Password=mypassword;MultipleActiveResultSets=True;App=EntityFramework&amp;quot;" providerName="System.Data.EntityClient"/&gt;
    &lt;/connectionStrings&gt;
  
    &lt;entityFramework&gt;
      &lt;defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"&gt;
        &lt;parameters&gt;
          &lt;parameter value="v11.0"/&gt;
        &lt;/parameters&gt;
      &lt;/defaultConnectionFactory&gt;
      &lt;providers&gt;
        &lt;provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/&gt;
      &lt;/providers&gt;
    &lt;/entityFramework&gt;
  
     &lt;startup&gt;
      &lt;supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/&gt;
     &lt;/startup&gt;
  
  &lt;/configuration&gt;
  </code></pre>
  
  <p>I set up my connection string using</p>
  
  <pre><code>private CartConnect MakeConnect()
  {
      string key = string.Format("CartConnect_{0}", Environment.MachineName.ToUpperInvariant());
      string constr = ConfigurationManager.ConnectionStrings[key].ConnectionString;
      var connect = new CartConnect(constr); // fails here
  
      connect.Configuration.LazyLoadingEnabled = false;
  
      connect.Configuration.ProxyCreationEnabled = false;
  
      return connect;
  }
  </code></pre>
  
  <p>I looked at other questions on "An error occurred creating the configuration section handler for entityFramework"</p>
  
  <p>I tried removing and re-adding Entity Framework using NuGet</p>
  
  <p>[Update]</p>
  
  <p>Thank you ErikEJ. Copying the files locally works.   I wonder if there is a way to get it working on the network?</p>
  
  <p>Reminds me of my problem <a href="https://mail.google.com/mail/u/0/?tab=wm#label/jtKnowledgebase/143a335874d62245" rel="nofollow">in this question about regasm</a></p>