February 2, 2010

Ignorance is not bliss. EventWaitHandle.OpenExisting throws WaitHandleCannotBeOpenedException

Filed under: .net,windows plateform Himanshu @ 12:06 pm

My development computer got upgraded to Windows 7, Windows 7 is good experience.

For one of our client, I needed to setup mechanics such that admin users should be able to initiate a process in Windows Service using GDI based .NET application. We had also developed the windows service in .NET. As both of them are .NET applications, there are more than one ways to IPC between them. As in this case there was only need to give signal to the service, I choose to do it through Windows Event. .NET BCL provides wrapper around Win32 functions to do this through type named EventWaitHandle.

I completed the code like I used to do in my old days, and tried the first use of it. On call to OpenExisting, client application failed with exception “No handle of the given name exists”. My first thought was that this could be because of UAC, but in that case it should say something like access violation. I tried running application in Windows 2003 Server and it worked perfectly. I decided to check documentation.

After some time I landed to msdn page for namespaces of kernel objects, which indicates that:

For processes started under a client session, the system uses the session namespace by default. However, these processes can use the global namespace by prepending the “Global\” prefix to the object name

changed my client code to have name prefixed with “Global\”, and everything started behaving the way I wanted it to in Windows 7 as well.


  1. This is the problem of dot Net programmers. They just don’t know the basics.

    Comment by Macao — December 28, 2011 @ 4:08 pm

  2. I wouldn’t phrase this as problem of missing basics.

    Comment by Himanshu — June 7, 2012 @ 10:43 am

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress