【发布时间】:2015-06-09 08:44:47
【问题描述】:
我们有一个将部署在使用 Entity Framework 6 和 SQL Server Express 的 Windows XP 上的应用程序。
应用程序的应用配置文件如下所示:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
<connectionStrings>
<add name="Rust" connectionString="Data Source=(ip here).\SQLEXPRESS;Initial Catalog=Rust;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
每当我们更改连接字符串以连接到实际服务器并且应用程序在 Windows 7 上运行时,它都可以正常工作。但如果它在 Windows XP 上运行,则会发生我们无法追踪的未处理异常:
当我们尝试从数据库中检索一些信息时会发生这种情况
Task.Factory.StartNew(() =>
{
//here
departments = new ObservableCollection<Department>(this.GetAllDepartments());
});
我们连接的 SQL Server 是 SQL Server 2012 Express。数据访问层上的 App 配置如下所示:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb"/>
</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>
【问题讨论】:
-
如果是未处理的异常,您应该能够捕获并记录它。
-
异常来自非ui线程,因此很难调试。
-
xp机器上是否安装了.net framework 4?
-
@JustinAizengard 是的
标签: c# windows sql-server-2012-express