【问题标题】:Unhandled exception running an application on Windows XP but works fine on Windows 7在 Windows XP 上运行应用程序但在 Windows 7 上运行良好的未处理异常
【发布时间】: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 是的
  • 我会先订阅TaskScheduler.UnobservedTaskException 事件。

标签: c# windows sql-server-2012-express


【解决方案1】:

这就是问题所在:

我们一直在使用一个名为 VirtualBox 的虚拟机,它安装了 Windows XP。我们尝试安装 Visual Studio 2010 并从那里调试应用程序,但没有成功。经过两天的思考,为什么这不起作用,我们尝试使用 VMWare 工作站,它运行良好!! VirtualBox 软件一定有某种问题。

谢谢大家的建议!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-15
    • 1970-01-01
    • 2011-03-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多