DEV Community

Cover image for Fixing the "SetThreadContext failed" Assertion Failure in Delphi 2007 on Modern Windows Machines, Including Windows 11
Michael Charles Aubrey
Michael Charles Aubrey

Posted on

Fixing the "SetThreadContext failed" Assertion Failure in Delphi 2007 on Modern Windows Machines, Including Windows 11

So the content of this article is readily available on other forums and places like Stack Overflow, but they all talk about this error in the context of much earlier versions of Windows. The information in those articles is still relevant, but you might like me hesitate to even try those solutions because they look so old. I'm writing this basically to put something online that says, "Yup, this fix works for Windows 11 too," for anyone else working on legacy Delphi applications here in the roarin' 2020s.

If you're working with Delphi 2007 on a modern Windows machine, you might have come across this error while attempting to close a VCL Forms application. You're greeted with an assertion failure saying, "SetThreadContext failed" in ..\win32src\thread32.cpp at line 412.

Assertion failure: "(!"SetThreadContext failed")" in ..\win32src\thread32.cpp at line 412 Continue execution?

Luckily there's a straightforward fix to this issue. The problem is caused by an outdated version of bordbk105N.dll that comes bundled with Delphi 2007. To resolve this, you need to replace it with an updated version of the file.

Here's what you need to do:

  1. First, download the updated version of bordbk105N.dll from Embarcadero's website: https://cc.embarcadero.com/item/27521. This file was initially released as a fix for Windows 7, but it works for Windows 11 as well.
  2. Next, locate the folder where your Delphi 2007 installation is. The default installation path is typically C:\Program Files (x86)\CodeGear\RAD Studio\5.0.
  3. Navigate to the bin folder within the Delphi 2007 installation folder.
  4. Find the existing bordbk105N.dll file and create a backup copy of it (e.g., bordbk105N.dll.bak). This step is essential in case you need to revert any changes.
  5. Replace the existing bordbk105N.dll file with the updated version you downloaded earlier.
  6. Restart the Delphi 2007 IDE and run your VCL Forms application again.

That's it! You should no longer encounter the "SetThreadContext failed" assertion failure when closing your VCL Forms application.

Top comments (0)