Skip to content

Attach to debug TwinCAT HMI Server Extension with just one click

The information in this post are usable with:

  • VisualStudio 2017, 2019
  • TE2000-HMI-Engineering 1.12.*.* (Download) and future releases
  • Sources of this post: GitHub Repository

Very often you have to implement your own business-logic in a TwinCAT HMI Server Extension (link: Beckhoff). To debug that extension you have to attach to the process which has loaded and runs the corresponding functionality. In TwinCAT HMI 1.12 the running process to execute that server extension has changed. In the TwinCAT HMI version 1.10 the server extension was loaded into the domain of the server process “tchmisrv.exe”. Because of security and stability reason the process has been sourced out to an individual process for any custom server extension.

In the following example a basic TwinCAT HMI Project has been created. In addition a basic TwinCAT HMI Server Extension is added to the solution. Both projects are weaved together by using the ctx-menu “Add Reference…” of the “References”-node within the HMI project.

The ServerExtensionCSharp1 project is referenced by the HMI project,
and the extension is loaded and running marked by the green arrow.

Open your prefered task manager to check the current process hierarchy of the TwinCAT HMI Server and the TwinCAT HMI Server Extension. As you can see the “TcHmiSrv.exe” process with the ‘Window Title’ “TcHmiSrv Engineering” is running, currently the process has two childs:

  • TcHmiSrv SysTray
  • TcHmiSrv (PID 18040): SeverExtensionCSharp1

The “TcHmiSrv SysTray” is not interesting for us.

The most interesting process is:

Solution: “Attach to Extension”

In Visual Studio you have to use the “Attach to Process”-dialog reachable by clicking “Debug / Attach to Process…” to start debugging of that individual process. In that dialog it is required to select a specific process you like to attach to. First pitball would be to search for the name of your extension, the result would be zero. Searching for the server process is the second pitball. Both processes are not correct. As a minimum you need four clicks to attach, a way to much work (and waste of dev-time)!

As stated at the begin of this post the extension is loaded in an individual domain / process. That process is named “TcHmiExtensionContainer” and you have to attach to that process. Not very intuitiv, right? We know!

Debug by one click!

To solve that useability issue the TwinCAT HMI provides a very smart way. Just open the context menu of your loaded and running TwinCAT HMI Server Extension named “ServerExtensionCSharp1” and click “Attach to Extension”.

As a result your Visual Studio switches to the debug view and breakpoints will be hit.


  1. Jon Jon

    Hello Christian,
    I do some HMI projects with TE2000_TC3_HMI_EN.pdf(V1.3) . But it has little server extension content. I have some questions, such as how to connect to mysql with server extension.Does we have some documents about server extensions?

    • I have sent you an e-mail to your provided e-mail address. Thanks for asking!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.