title: Starting a .NET process within an AppDomain
body: <p>The title of my question might already give away the fact that I'm not sure about what I want, as it might not make sense.</p>
  
  <p>For a project I want to be able to run executables within my application, while redirecting their standard in and out so that my application can communicate with them through those streams.</p>
  
  <p>At the same time, I do not want to allow these executables to perform certain actions like use the network, or read/write outside of their own working directory (basically I only want to allow them to write and read from the standard in and out).</p>
  
  <p>I read on different places on the internet that these permissions can be set with PermissionStates when creating an AppDomain in which you can then execute the executables. However, I did not find a way to then communicate with the executables through their standard in and out, which is essential. I can however do this when starting a new Process (<code>Process.Start()</code>), though then I cannot set boundaries as to what the executable is allowed to do.</p>
  
  <p>My intuition tells me I should somehow execute the Process inside the AppDomain, so that the process kind of 'runs' in the domain, though I cannot see a way to directly do that.</p>
  
  <p>A colleague of mine accomplished this by creating a proxy-application, which basically is another executable in which the AppDomain is created, in which the actual executable is executed. The proxy-application is then started by a Process in the main application. I think this is a cool idea, though I feel like I shouldn't need this step.</p>
  
  <p><em>I could add some code containing what I've done so far creating a process and appdomain, though the question is pretty long already. I'll add it if you want me to.</em></p>