none
Named Semaphore Problem in Vista RRS feed

  • Question

  •  

    I am creating a named semaphore in a service under vista. The out boolean returns true to indicate that the semaphore was successfully created.

     

    When I attempt to open the semaphore in my client app on the same machine using OpenExisting(name) I get the WaitHandleCannotBeOpenedException.

     

    I also have a console application which provides all the service functionality which I use for development. Both the console and service use the same class for creating the semaphore. When using the console, the semaphore is accessible by the client.

     

    Also, the same code runs fine on my XP box.

     

    This has got me stumped. Any pointers would be appreciated.

     

    Thanks.

    Wednesday, June 25, 2008 1:25 PM

Answers

  • I suspect that the console and client applications are running under filtered credentials (e.g. standard user or filtered admin credentials) and the service is running under administrator credentials.  If that's the case, you won't be able to access the event if the service creates it because it's created with a high integrity level.

    Another reason I can think of is that services run under Session 0 in Vista, and different sessions have different kernel object namespaces.  If you haven't yet done so, add Global\ to the event name.
    Sasha Goldshtein | http://blogs.microsoft.co.il/blogs/sasha
    • Marked as answer by teaboy Wednesday, June 25, 2008 4:13 PM
    Wednesday, June 25, 2008 2:17 PM

All replies

  • I suspect that the console and client applications are running under filtered credentials (e.g. standard user or filtered admin credentials) and the service is running under administrator credentials.  If that's the case, you won't be able to access the event if the service creates it because it's created with a high integrity level.

    Another reason I can think of is that services run under Session 0 in Vista, and different sessions have different kernel object namespaces.  If you haven't yet done so, add Global\ to the event name.
    Sasha Goldshtein | http://blogs.microsoft.co.il/blogs/sasha
    • Marked as answer by teaboy Wednesday, June 25, 2008 4:13 PM
    Wednesday, June 25, 2008 2:17 PM
  • Had considered the admin credentials initially, though the account in question has full admin rights.

    However you were right on the money with the problem being "session 0" related. Must admit being new to Vista development and although I had come across the "session 0" concept, wasn't fully aware of the impacts in this instance. Adding "Global/" worked nicely.

    Many thanks.

    Wednesday, June 25, 2008 4:17 PM
  • @teaboy Thanks for raising the question. I've been struggling with the same issue for a couple of hours now. :-(

    @Sasha Thanks for the answer. Works as expected now.
    Friday, October 17, 2008 2:32 PM