Kind people in the comments pushed me into different ideas and I was able to find and fix the issue.
The issue was the path in this method below, System32
was missing.
private bool IsWinPE()
{
string windowsDir = "X:\\Windows\\System32";
return File.Exists(Path.Combine(windowsDir, "winpeshl.ini")) ||
File.Exists(Path.Combine(windowsDir, "startnet.cmd"));
}
It was my mistake, but this error misguided me and I was looking completely different directions. So if someone will have same problem, this answer may be the solution. Thanks