From a C# program, I am executing a byte[] containing another .NET console-application directly in memory using the 'Invoke' method, with this code:
static void Main(string[] args)
{
byte[] Bytes = File.ReadAllBytes("C:\\test.exe");
Assembly a = Assembly.Load(FileBytes);
MethodInfo m = a.EntryPoint;
var parameters = m.GetParameters().Length == 0 ? null : new[] { new string[0] };
m.Invoke(null, parameters);
}
However, as the console-application that I am launching in memory ("C:\test.exe") never ends (it uses a while forever loop), the black cmd window never disappears.
How can it be executed hidden? As now I cannot use for example 'System.Diagnostics.ProcessWindowStyle.Hidden'
as the process is not in disk.