Xbox LIVE Indie Games
Sort Discussions: Previous Discussion Next Discussion
Page 1 of 1 (7 posts)

Failed to create Direct3D device when running application as windows service

Last post 9/27/2014 5:53 PM by Charybdis. 6 replies.
  • 5/8/2007 4:01 AM

    Failed to create Direct3D device when running application as windows service

    Does anyone know of any issues of running Direct3D inside windows service application ?
    The video application I am working on currently cannot create Direct3D device when ran as windows service.
    When I ran it in debug mode (with its own console), the application could run and I could play video with
    Direct3D.

    Does anybody know possible reasons of this behavior ?

    Thanks,
    Celios27
  • 5/8/2007 5:07 AM In reply to

    Re: Failed to create Direct3D device when running application as windows service

    Why would you want to use DirectX in a Service? Service are not normal applications, e.g. they might run in their own session/desktop, which is not viewable by the user. It is way safer and recommaned to move the DX code into a user application and let the service communicate with this application about what it should display.

  • 5/8/2007 5:08 AM In reply to

    Re: Failed to create Direct3D device when running application as windows service

    Answer
    Reply Quote

    With this question there are two main things to consider. The first is that a direct3d device needs to have a display or Visual component, and the second is that a windows service is designed to run in the background where there is no display availible to it.

    So the answer is not it can not run in a service. If you would like to a have a visual component that displays information that is collected from a service, these would be two different applications and have a communications layer between them. Have a look at socket communication, or remoting..

  • 5/8/2007 8:10 PM In reply to

    Re: Failed to create Direct3D device when running application as windows service

    Thanks for the replies. :D
  • 10/13/2008 7:36 PM In reply to

    Re: Failed to create Direct3D device when running application as windows service

    Somebody on Gamedev.net suggested changing the settings in the "Log on" tab of the service's properties, to use the Local System account, and check the "Allow service to interact with desktop" box. This seems to work for me, it's not an XNA application but my CruiseControl.NET service is launching a commandlet that generates thumbnails using D3D9, and I had the same problem as you initially.

    @Bjoern: I guess you would want to use DirectX in a service for the same exact reasons you would want to run any other app :)  In the company I work for, we currently have 12 build servers performing various tasks for our game, and mostly I want everything to restart automatically when they reboot (for example, after some Windows update was pushed), without any user having to log in.

    Frederic

  • 9/27/2014 2:51 AM In reply to

    Re: Failed to create Direct3D device when running application as windows service

    no.

    There is no such requirement that the operations your kicking off on the gpu would ever require a "PRESENT" call issued.  

    There are literally hundreds of reason why someone would want to create a direct 3d device, and push work to the gpu, and still never push anything to the screen.

    Its this kind of narrow minded thinking that has locked out and prevented real innovation from occurring on windows platforms.
  • 9/27/2014 5:53 PM In reply to

    Re: Failed to create Direct3D device when running application as windows service

    Answer
    Reply Quote
    Direct3D 9 was never designed to run from a service. The session 0 isolation feature introduced in Windows Vista greatly improved system security, but a consequence of that was that the drivers were inaccessible from a Windows service.

    http://support2.microsoft.com/kb/978635

    With Direct3D 10 and Direct3D 11 on Windows 7 / Windows Server 2008 R2, it is possible to get a Direct3D NULL or WARP device to work from session 0 (i.e. a Windows service) but not a HARDWARE device. The GPU is still not accessible in this situation.

    As of Windows 8 / Windows Server 2012, Direct3D 11 will work from a Windows service including HARDWARE device access. Obviously nothing that creates or uses a swap chain can work since there's no desktop session to attach to.

    http://msdn.microsoft.com/en-us/library/windows/desktop/hh404562(v=vs.85).aspx#use_direct3d_in_session_0_processes

    PS: Another issue that affects the scenario above is that even if you are able to 'log in' to kick of a desktop session, the GPU is not accessible when showing the 'secure desktop' (i.e. the system is locked, during a login attempt, or when UAC admin prompt is active) when using the legacy Direct3D 9 API. It considers this a 'lost device' scenario. All newer WDDM-aware APIs (Direct3D9Ex, Direct3D10.x, Direct3D 11.x, etc.) behave much more reasonably with the 'secure desktop' active.
Page 1 of 1 (7 posts) Previous Discussion Next Discussion