gpt4 book ai didi

unit-testing - .Net 3.5 测试项目的单元测试不适用于 VS 2012

转载 作者:行者123 更新时间:2023-12-04 17:50:30 24 4
gpt4 key购买 nike

我有一个 Visual Studio 2012,其中有(让我们简单点)2 个项目:

  • MyProject(类库)
  • MyProject.Test(MS 测试项目)

  • 因为我必须针对 .Net 3.5,所以我 retarget the test project's framework .

    然而,此时,单元测试停止工作(如果我离开 4.5,它工作)。

    具体来说,QTAgent.exe 崩溃:
    [Window Title]
    QTAgent.exe

    [Main Instruction]
    QTAgent.exe has stopped working

    [Content]
    A problem caused the program to stop working correctly. Please close the program.

    [Close the program] [Debug the program]

    在 Visual Studio 的输出窗口中,我可以看到:
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_64\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 11.0\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\vstest.executionengine.clr20.exe', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 11.0\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\Microsoft.VisualStudio.TestPlatform.TestExecutor.Core.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\System.ServiceModel\3.0.0.0__b77a5c561934e089\System.ServiceModel.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 11.0\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\Microsoft.VisualStudio.TestPlatform.Core.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 11.0\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Runtime.Serialization\3.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\SMDiagnostics\3.0.0.0__b77a5c561934e089\SMDiagnostics.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\System.WorkflowServices\3.5.0.0__31bf3856ad364e35\System.WorkflowServices.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\System.ServiceModel.Web\3.5.0.0__31bf3856ad364e35\System.ServiceModel.Web.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.Diagnostics.ServiceModelSink\3.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Diagnostics.ServiceModelSink.dll', Symbols loaded.
    A first chance exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll
    A first chance exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\System.IdentityModel\3.0.0.0__b77a5c561934e089\System.IdentityModel.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Core\3.5.0.0__b77a5c561934e089\System.Core.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_64\System.Transactions\2.0.0.0__b77a5c561934e089\System.Transactions.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 11.0\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\Microsoft.VisualStudio.TestPlatform.Utilities.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.Diagnostics.Measurement\11.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Diagnostics.Measurement.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 11.0\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\Extensions\Microsoft.VisualStudio.TestPlatform.Extensions.dll', Symbols loaded.
    A first chance exception of type 'System.BadImageFormatException' occurred in mscorlib.dll
    A first chance exception of type 'System.BadImageFormatException' occurred in mscorlib.dll
    A first chance exception of type 'System.BadImageFormatException' occurred in mscorlib.dll
    A first chance exception of type 'System.BadImageFormatException' occurred in mscorlib.dll
    A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 11.0\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\Extensions\Microsoft.VisualStudio.TestPlatform.Extensions.TmiAdapter.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PrivateAssemblies\Microsoft.VisualStudio.TeamSystem.Licensing.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.QualityTools.Common\11.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.QualityTools.Common.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 11.0\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\Extensions\Microsoft.VisualStudio.TestPlatform.Extensions.TrxLogger.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 11.0\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\Extensions\Microsoft.VisualStudio.TestPlatform.Extensions.VSTestIntegration.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.QualityTools.UnitTestFramework\10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_64\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll', Symbols loaded.
    A first chance exception of type 'System.BadImageFormatException' occurred in mscorlib.dll
    A first chance exception of type 'System.BadImageFormatException' occurred in mscorlib.dll
    A first chance exception of type 'System.BadImageFormatException' occurred in mscorlib.dll
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_64\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PrivateAssemblies\Microsoft.VisualStudio.Enterprise.AspNetHelper.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.QualityTools.ExecutionCommon\11.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.QualityTools.ExecutionCommon.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.QualityTools.Resource\11.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.QualityTools.Resource.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.QualityTools.TMI\11.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.QualityTools.TMI.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_64\System.Web\2.0.0.0__b03f5f7f11d50a3a\System.Web.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel\11.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.QualityTools.Tips.UnitTest.Tip\11.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.QualityTools.Tips.UnitTest.Tip.dll', Symbols loaded.
    A first chance exception of type 'System.BadImageFormatException' occurred in mscorlib.dll
    A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'Microsoft.VisualStudio.TestTools.Exceptions.EqtDataException' occurred in Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel.dll
    A first chance exception of type 'Microsoft.VisualStudio.TestTools.Exceptions.EqtDataException' occurred in Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel.dll
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.QualityTools.Tips.UnitTest.AssemblyResolver\11.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.QualityTools.Tips.UnitTest.AssemblyResolver.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\Projects\_Shared\MyCorp.Shared\Src\MyCorp.MyProject\MyCorp.MyProject.Test\bin\Debug\MyCorp.MyProject.Test.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PrivateAssemblies\Microsoft.VisualStudio.QualityTools.Controller.SpooledJob.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.QualityTools.ControllerObject\11.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.QualityTools.ControllerObject.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.QualityTools.AgentProcessManager\11.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.QualityTools.AgentProcessManager.dll', Symbols loaded.
    'vstest.executionengine.clr20.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Runtime.Remoting\2.0.0.0__b77a5c561934e089\System.Runtime.Remoting.dll', Symbols loaded.
    'QTAgent_35.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_64\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll', Symbols loaded.
    'QTAgent_35.exe' (Managed (v2.0.50727)): Loaded 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\QTAgent_35.exe', Symbols loaded.
    'QTAgent_35.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll', Symbols loaded.
    'QTAgent_35.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.QualityTools.ExecutionCommon\11.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.QualityTools.ExecutionCommon.dll', Symbols loaded.
    'QTAgent_35.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.QualityTools.Common\11.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.QualityTools.Common.dll', Symbols loaded.
    'QTAgent_35.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.QualityTools.Resource\11.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.QualityTools.Resource.dll', Symbols loaded.
    'QTAgent_35.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.QualityTools.AgentObject\11.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.QualityTools.AgentObject.dll', Symbols loaded.
    'QTAgent_35.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll', Symbols loaded.
    'QTAgent_35.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll', Symbols loaded.
    'QTAgent_35.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Core\3.5.0.0__b77a5c561934e089\System.Core.dll', Symbols loaded.
    'QTAgent_35.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Runtime.Remoting\2.0.0.0__b77a5c561934e089\System.Runtime.Remoting.dll', Symbols loaded.
    'QTAgent_35.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.QualityTools.AgentProcessManager\11.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.QualityTools.AgentProcessManager.dll', Symbols loaded.
    'QTAgent_35.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_64\System.Web\2.0.0.0__b03f5f7f11d50a3a\System.Web.dll', Symbols loaded.
    'QTAgent_35.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel\11.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel.dll', Symbols loaded.
    'QTAgent_35.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_64\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll', Symbols loaded.
    'QTAgent_35.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.QualityTools.UnitTestFramework\10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll', Symbols loaded.
    'QTAgent_35.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.QualityTools.Tips.UnitTest.Adapter\11.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.QualityTools.Tips.UnitTest.Adapter.dll', Symbols loaded.
    'QTAgent_35.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.QualityTools.Tips.UnitTest.AssemblyResolver\11.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.QualityTools.Tips.UnitTest.AssemblyResolver.dll', Symbols loaded.
    'QTAgent_35.exe' (Managed (v2.0.50727)): Loaded 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PrivateAssemblies\Microsoft.VisualStudio.TeamSystem.Licensing.dll', Symbols loaded.
    'QTAgent_35.exe' (Managed (v2.0.50727)): Loaded 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PrivateAssemblies\Microsoft.VisualStudio.Enterprise.AspNetHelper.dll', Symbols loaded.
    The program '[7756] QTAgent_35.exe: Managed (v2.0.50727)' has exited with code -1073740940 (0xc0000374).
    The thread 'TestAgentProcessMonitor' (0x1854) has exited with code 0 (0x0).
    The thread 'Local run message listener test message receiver cleanup thread' (0x2110) has exited with code 0 (0x0).
    A first chance exception of type 'System.InvalidCastException' occurred in Microsoft.VisualStudio.QualityTools.ControllerObject.dll
    The thread 'Controller: Release worker thread for agent SP2010' (0x18ac) has exited with code 0 (0x0).
    A first chance exception of type 'System.Threading.ThreadInterruptedException' occurred in Microsoft.VisualStudio.QualityTools.ControllerObject.dll
    The thread 'Controller: heartbeat thread' (0x1db0) has exited with code 0 (0x0).
    The thread 'Controller: state execution thread for run d7a5f846-868c-486b-ae22-40d27396a225' (0x1e1c) has exited with code 0 (0x0).
    The thread 'Controller: run queue thread' (0x23ec) has exited with code 0 (0x0).
    The thread 'Controller: deployment queue thread' (0x25ec) has exited with code 0 (0x0).
    The thread '<No Name>' (0x128c) has exited with code 0 (0x0).
    The thread '<No Name>' (0x2028) has exited with code 0 (0x0).
    A first chance exception of type 'System.InvalidOperationException' occurred in Microsoft.VisualStudio.TestPlatform.TestExecutor.Core.dll
    A first chance exception of type 'System.ServiceModel.CommunicationObjectAbortedException' occurred in System.ServiceModel.dll
    A first chance exception of type 'System.InvalidOperationException' occurred in Microsoft.VisualStudio.TestPlatform.TestExecutor.Core.dll
    A first chance exception of type 'System.ServiceModel.CommunicationObjectAbortedException' occurred in System.ServiceModel.dll
    The program '[6200] vstest.executionengine.clr20.exe: Managed (v2.0.50727)' has exited with code 0 (0x0).

    如果我将调试器附加到 QTAgent.exe 进程,我可以看到此堆栈跟踪:

    Stacktrace

    有人知道为什么我的设置不起作用,以及如何解决它?

    对于一些背景知识,我正在创建 SharePoint 2010 单元测试,因此我将测试项目设置为面向 .Net 3.5(SharePoint 不适用于 CLR 4)。

    我还将测试项目设置为在 64 位主机中运行。

    最佳答案

    我实际上无法解释为什么,但我删除了 mysolution.v11.suo文件,测试开始工作。

    实际上,不同之处在于我不再有测试设置文件( .testsettings )。

    我不得不删除 suo 文件,因为 VS 2012 不允许取消选择测试设置文件。

    我还必须强制使用 X64 模式(我的托管应用程序 SharePoint 的要求)。但这一次,我没有在测试设置文件中设置模式,而是使用 TEST->TEST SETTINGS->DEFAULT PROCESSOR ARCHITECTURE-> X64 进行设置。

    关于unit-testing - .Net 3.5 测试项目的单元测试不适用于 VS 2012,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17672054/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com