My goal is to isolate some code execution for NET Core.
- I have a console application #1 (parent?), which starts a process for another console application #2 (child?), which in turn runs dynamically compiled code.
- Execution of that code may result in fatal error, e.g., OutOfMemoryException.
- When it happens, then the application #1 fails along with the application #2.
Is there a way to save the application #1 from the fail of the application #2?
Maybe I misunderstand something, but I thought that these should be totally separate. Please help. Will appreciate a solution for NET Framework as well, if any.
ProcessStartInfo processStartInfo = new ProcessStartInfo(filePath, processArgs)
{
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
};
using (Process process = new Process()
{
StartInfo = processStartInfo,
EnableRaisingEvents = true
})
{
process.Start();
process.WaitForExit();
return process.StandardOutput.ReadToEnd();
};