0

Using Win32 I can create kernel objects which have their handles inherited to child processes (e.g. CreateEvent with SECURITY_ATTRIBUTES.bInheritHandle = true). Although I can get the same result by using P/Invoke I'm wondering why this functionality has not been made available by the framework class library even though System.Diagnostics.Process.Start() calls Win32's CreateProcess with bInheritHandles = true.

Is this technique outdated, not safe or just not very well known?

Ðаn
  • 10,934
  • 11
  • 59
  • 95
alerosmile
  • 79
  • 1
  • 7
  • 2
    The goal of the .NET framework was not to mirror the complete Win32 API surface. Remember that [every feature starts with −100 points](https://blogs.msdn.microsoft.com/ericgu/2004/01/12/minus-100-points/). Furthermore, P/Invoke exists and works, so it's not like you can't do it. It's just that you can't do it conveniently. I guess in the 15 years .NET has existed now it hasn't been such a pressing issue for most developers. Another thing to keep in mind is that many parts of .NET were designed to be agnostic of the underlying OS, even though for many years only Windows was a target. – Joey Apr 03 '17 at 15:10
  • 1
    It is too broken to give .NET programmers a shot at using it correctly. Raymond Chen noodles about [what they did at Vista](https://blogs.msdn.microsoft.com/oldnewthing/20111216-00/?p=8873) to make it actually work properly. Having to stay compatible across Windows versions was one reason that prevented this from getting added to .NET. – Hans Passant Apr 03 '17 at 16:00

0 Answers0