OpenExisting throws exception and makes ProcessThreads fail
Opened this issue · 6 comments
I am trying to use your library to run a pretty time and memory consuming task in a separate process.
The scenario is this: a plugin for sharp develop, which edits an XML file and then generates code from that file. I want to run the code generation in a separate process, to ease up the memory load of sharp develop.
I tried a small sample project and everything works well, but when I use your library inside the SD plugin, I get an error when the new process is started. It seems an event wait handle is created in a process and waited in the new born process, but this second process cannot reach it and throws a WaitHandleCannotBeOpenedException
Do you have any idea on how to investigate or fix this?
Thanks,
Luca
Hi Luca,
Would be nice if you provide a bit more info.
Does it get any stack trace?
Is there anything special in privileges?
It's a pretty silent error. I can see something's gone wrong because my application just doesn't do what it's supposed to. I tried debugging the whole thing and when it gets down to StartVariableParamsAndResult I can see that as soon as the external process is started the Exited event is signaled and if I read the error lines in the ProcessThread object I can see the above mentioned WaitHandleCannotBeOpenedException.
Curious enough, when I am debugging if I try to call OpenExisting in the immediate window I can get the handle with no problem, but I guess it happens because I am in the same process that created it.
I read about privileges troubles around, but I cannot understand how it fits to my plugin, since if that's the error it would mean that my app + plugin are running on a higher privilege than the external process created by your library, which would be quite strange
sorry... closed it without meaning to...
proc.ErrorLines
Count = 5
[0]: ""
[1]: "unhandled exception: System.Threading.WaitHandleCannotBeOpenedException: no handle of the given name exists."
[2]: " in System.Threading.EventWaitHandle.OpenExisting(String name, EventWaitHandleRights rights)"
[3]: " in AZI.ProcessThreads.ProcessThreadExecutor.Main(String[] args)"
[4]: null
I downloaded the source code from GitHub, fixed it so that it can compile in VS2013, compiled and added a reference to this freshly compiled assembly and tada! it works!... so... why does the nuget version cause troubles? can it be a strange kind of incompatibility between c# 5.0 and c# 6.0?
Oh, sorry, I was/am sick and did not respond. I will test it with different .net versions. Thanks for spending your time, did not expect that library I made just for fun when had nothing to do at work is really needed for anyone.