C# '的类型初始值设定项;System.Data.Entity.Internal.AppConfig';引发了Windows XP的异常

C# '的类型初始值设定项;System.Data.Entity.Internal.AppConfig';引发了Windows XP的异常,c#,wpf,entity-framework,windows-xp-sp3,C#,Wpf,Entity Framework,Windows Xp Sp3,我的WPF应用程序在Windows 7上运行良好,但在Windows XP上运行时会抛出上述错误。 我使用的是实体框架6.1.1 App.xaml是 <Application.Resources> <main:MainConverter x:Key="MainVerter"/> <Style x:Key="DetailHead1Style" TargetType="TextBlock"> <Setter Property=

我的WPF应用程序在Windows 7上运行良好,但在Windows XP上运行时会抛出上述错误。 我使用的是实体框架6.1.1

App.xaml是

<Application.Resources>
    <main:MainConverter x:Key="MainVerter"/>
    <Style x:Key="DetailHead1Style" TargetType="TextBlock">
        <Setter Property="FontSize" Value="20"/>
        <Setter Property="FontWeight" Value="Bold"/>
        <Setter Property="Foreground" Value="DarkSlateGray"/>
        <Setter Property="Opacity" Value="0.8"/>
        <Setter Property="FontStyle" Value="Italic"/>
        <Setter Property="Margin" Value="6,2,6,2"/>
    </Style>
    <Style  x:Key="DetailsOuterGridStyle" TargetType="Grid">
        <Setter Property="Background" Value="White"/>
    </Style>
</Application.Resources>

app.config包含正确的连接字符串。在XP上是否可以有不同的解释

[更新] 初始化连接时代码失败

 var connect = new CartConnect(constr);
[更新]

app.config是

 <?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
  </configSections>

  <connectionStrings>
    <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=&quot;Database=mydatabase;Server=Server15\SQLExpress;Integrated Security=False;User=mylogin;Password=mypassword;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient"/>
  </connectionStrings>

  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0"/>
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
    </providers>
  </entityFramework>

   <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
   </startup>

</configuration>
我看了关于“为entityFramework创建配置节处理程序时出错”的其他问题

我尝试使用NuGet删除并重新添加实体框架

[更新]

谢谢你,埃里克。在本地复制文件是可行的。我想知道是否有办法让它在网络上工作


让我想起了我的问题

Q:drive是本地的吗?如果没有,请尝试从本地驱动器运行应用程序-错误消息表明存在安全问题,无法从网络文件夹运行。

请发布app.xaml文件。@PiyushParashar我已用app.xamli更新了该问题是否存在内部异常?你能调试app.g.cs文件吗?你需要捕获异常并记录内部异常外部异常不提供任何有用的信息。th Q:驱动器是本地的吗?如果没有,请尝试从本地驱动器运行应用程序
 <?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
  </configSections>

  <connectionStrings>
    <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=&quot;Database=mydatabase;Server=Server15\SQLExpress;Integrated Security=False;User=mylogin;Password=mypassword;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient"/>
  </connectionStrings>

  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0"/>
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
    </providers>
  </entityFramework>

   <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
   </startup>

</configuration>
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;
}