'TcpListener stop working when the program is open by a Windows Service

I write a program that listen a tcp port and read the incoming packet.

If I open the program with double-click it works fine and report 31 bytes (the correct amount).

If I open the program with another application it report 9 bytes (that are completely different from the 31 bytes) even if I start the program as admin user:

Process.Start(programPath);

or with admin permission:

Process process = new Process();
process.StartInfo.UseShellExecute = false;
process.StartInfo.WorkingDirectory = programPath;
programPath += "\\Save Log.exe";
process.StartInfo.FileName = programPath;
process.StartInfo.Domain = "MY-DOMAIN";
process.StartInfo.UserName = "Account";
process.StartInfo.Password = password;
process.Start();


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source