Issue when using JobObject from a service

Jan 8, 2009 at 2:43 PM
Hello,

I found this great API and tried to use it inside my service that spawns a process.

First i tried the following (runned by a service under LocalSystem user account) :
- create a new Process with some ProcessStartInfo("calc.exe") 
- start the Process
- create a  JobObject with Limits.JobMemoryLimit large enough and added a jobEventHandler to Events.OnJobMemoryLimit
- No exceptions are thrown and the process exits with code 0.
- Marshal.GetLastWin32Error() gives no relevant information.

Second i tried use the CreateProcessMayBreakAway() from the JobObject without any limits and event handlers and the process doesn't even start, no exceptions are thrown.

Third i tried CreateProcessSecured() in the same conditions and when i access its id the following exception is thrown :
System.Runtime.Remoting.RemotingException: Failed to write on the IPC port : The communication channel is being closed.
Server stack trace:
   à System.Runtime.Remoting.Channels.Ipc.IpcPort.Write(Byte[] data, Int32 offset, Int32 size)
   à System.Runtime.Remoting.Channels.Ipc.PipeStream.Write(Byte[] buffer, Int32 offset, Int32 count)
   à System.Runtime.Remoting.Channels.ChunkedMemoryStream.WriteTo(Stream stream)
   à System.Runtime.Remoting.Channels.Ipc.IpcClientHandler.SendRequest(IMessage msg, ITransportHeaders headers, Stream contentStream)
   à System.Runtime.Remoting.Channels.Ipc.IpcClientTransportSink.ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, ITransportHeaders& responseHeaders, Stream& responseStream)
   à System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(IMessage msg)

Exception rethrown at [0]:
   à System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   à System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   à System.Diagnostics.Process.get_Id()

Does anybody managed to use this API from a windows service ?