Process network = new Process(); network.StartInfo.RedirectStandardOutput = true; network.StartInfo.RedirectStandardInput = true; network.StartInfo.CreateNoWindow = true; network.StartInfo.UseShellExecute = false; network.StartInfo.FileName = Application.StartupPath + @"\Solver\bin\deepcl_predict.exe"; network.StartInfo.Arguments = "weightsfile=\"" + Application.StartupPath + "\\Solver\\weights.dat\""; network.Start(); Thread.Sleep(5000); // give it some time to load List data = new List(12); data.AddRange(BitConverter.GetBytes(3)); data.AddRange(BitConverter.GetBytes(96)); data.AddRange(BitConverter.GetBytes(96)); Bitmap bmp = new Bitmap(Application.StartupPath + "\\test.jpeg"); List r = new List(9216 * 4); List g = new List(9216 * 4); List b = new List(9216 * 4); unsafe { BitmapData bitmapData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, bmp.PixelFormat); int bytesPerPixel = Image.GetPixelFormatSize(bmp.PixelFormat) / 8; int heightInPixels = bitmapData.Height; int widthInBytes = bitmapData.Width * bytesPerPixel; byte* ptrFirstPixel = (byte*)bitmapData.Scan0; int index = 0; for (int y = 0; y < heightInPixels; y++) { byte* currentLine = ptrFirstPixel + (y * bitmapData.Stride); for (int x = 0; x < widthInBytes; x = x + bytesPerPixel) { r.AddRange(GetBytes((float)currentLine[x + 2])); // red g.AddRange(GetBytes((float)currentLine[x + 1])); // green b.AddRange(GetBytes((float)currentLine[x])); // blue index++; } } bmp.UnlockBits(bitmapData); } List imageData = new List(((9216 * 4) * 3)); imageData.AddRange(r); imageData.AddRange(g); imageData.AddRange(b); try { network.StandardInput.BaseStream.Write(data.ToArray(), 0, 12); network.StandardInput.BaseStream.Write(imageData.ToArray(), 0, imageData.Count); // crashes here network.StandardInput.BaseStream.Flush(); } catch { } while (true) { Thread.Sleep(100); string tmpData = network.StandardOutput.ReadLine(); if (tmpData.Length > 3) Logg(tmpData); // same as console.writeline }