I'm trying to run TwinCat 3 XAR in a PC where I need to have hyper-V ON to run Azure IoT Edge (which uses hyper-V). Is there a way to run XAR with hyper-V turned on? Is there any way to isolate the cores from hyper-v or something else?
2 Answers
Edit 22 April 2022
For a complete tutorial on this see my blog post.
There is a way to accomplish this. You can do this by instead of having a local runtime, you can run the code on a runtime in a virtual machine. I got the idea from this reddit post.
To make it work I did the following:
Download and install VMware Player. Its free for non-commercial use. You can also use the paid Pro (Workstation) version. I'm not sure if this also works with Virtual Box.
Install TwinCAT BSD on the virtual machine as described in this excellent YouTube video by Jakob
If you're using VMware Player and need to enable UEFI you need to do the following as noted by YouTube user Eivind Hilde:
- Follow the guide in the video, but skip the step where the firmware type is set.
- Try to boot the VM. it will fail.
- Open the .vmx file in the VM directory with notepad .
- Find "firmware = "bios" and replace with "firmware ="efi"" and save. If this line doesn't exist, just add it somewhere.
- It will now boot, and you can follow the guide in the video for the rest.
Run your TwinCAT project on the virtual machine, without the need to disable Hyper-V.
Previous answer
I don't think so. InfoSys mentions:
Hyper-V environment:
- The runtime environment cannot be started inside a Hyper-V environment. This refers in particular to virtual Hyper-V machines, which are run in a privileged Hyper-V machine. As soon as a component of the computer uses Hyper-V, only the engineering environment (XAE) can be used on this computer, not the runtime environment (XAR).
But they also mention that:
- TwinCAT attempts to detect these Hyper-V environments; however, it is in the nature of virtualization approaches that they do not wish to be detected and TwinCAT therefore cannot carry out any 100% detection.
So maybe there is some way you can prevent TwinCAT from detecting a Hyper-V environment. However, that is something I can't answer.

- 2,459
- 16
- 43
-
interesting, I am able to run TwinCAT 3 PLC programs just fine in my Hyper-V virtual machine. My host OS is Windows 11. No VMware Player installation was necessary. – markonovak May 25 '23 at 15:58
you shall consider running the TwinCAT on the host and UI with other machine related tools on Virtual Machine. for this Beckhoff has TCBSD which basically FreeBSD with tweaked scheduler and TwinCAT 3 XAR installed. Note that TwinCAT 3 relies on Intel vt-d, and virtual machines are using that resource, and do not emulate processor with Vt-d thus no 2nd application can exist on the host OS or even more on guest OS to use hardware assisted virtualization.

- 65
- 7