testhost.exe crush with access violation exception


I have an unhandled exception in my code which crush my testhost.exe process and fails my azure pipeline build (exactly within the VSTest task).

Exception: 0xC0000005: Access violation read location 0xFFFFFFFFFFFFFFFF

After analysing the dump file of the crush I found that this exception appears when I try to save my pdf document in the specified stream using the "save" method of the "PdfManger" class, I am using the Select.Pdf.x64 library.

For information: I'm migrating my build from xaml builds to azure pipeline builds with upgrading the test framework from MSTest to MSTestV2, I'm building my projects using the MSBuild task with the "release" configuration and with "Any CPU" as a platform,for "VSTest" Task I'm using "x64" as a build platform, "release" as a configuration, MSTest.TestAdapter.2.1.1 as a test adapter, I'm using VS 2019 and here is the runsetting file:

<?xml version="1.0" encoding="utf-8"?>
  <!-- Configurations that affect the Test Framework -->
      <DataCollector friendlyName="blame" enabled="True">
          <CollectDump />
          <CollectDump />
      <Logger friendlyName="blame" enabled="True" />


I have tried to catch the exception with decorating the method responsible for the exception using the decorators "[HandleProcessCorruptedStateExceptions, SecurityCritical] but without success :( .

Anyone have a solution ?

asked on Stack Overflow Aug 13, 2020 by hergli sedki

2 Answers


testhost.exe crush with access violation exception

There is a know issue starting from Visual Studio 2019 16.4.3.

To resolve this issue, please try to update your Visual Studio 2019 to the latest version.

answered on Stack Overflow Aug 14, 2020 by Leo Liu-MSFT

Downgrading to mstest v1 everything works fine, it seems related to the QTAgent process because only mstest v1 launch QTAgent process through testhost process. ​ ​Thks for help :)

answered on Stack Overflow Aug 25, 2020 by hergli sedki

User contributions licensed under CC BY-SA 3.0