title: D3DERR_NOTAVAILABLE in unit test on Teamcity Build Server
body: <p>For the sake of testing a visual WPF control library which uses DirectX, I have created a few Unit Tests which create a DirectX scene, screenshot, then compare vs. expected image. </p>
  
  <p><em>I'm aware that this is a fragile unit testing technique (visual comparison) however it helps us to cover a large number of possible combinations.</em> </p>
  
  <p>The problem I have is the tests run locally just fine, but fail on the build server with error:</p>
  
  <pre><code>SharpDX.SharpDXException : HRESULT: [0x8876086A], Module: 
  [SharpDX.Direct3D9], ApiCode: [D3DERR_NOTAVAILABLE/NotAvailable], Message: Unknown
     at SharpDX.Result.CheckError()
     at SharpDX.Direct3D9.D3D9.Create9Ex(Int32 sDKVersion, Direct3DEx arg1)
     at SharpDX.Direct3D9.Direct3DEx..ctor()
  </code></pre>
  
  <p>However, if I log in to the build server and run the tests, they pass! (See below)</p>
  
  <p><a href="https://i.stack.imgur.com/CtPdk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CtPdk.jpg" alt="Unit Tests when run on server - pass!"></a></p>
  
  <p>The build server is Windows Server 2012 R2 and has DirectX10 Warp (software) drivers. </p>
  
  <p>I suspect that <a href="https://stackoverflow.com/q/1024832/303612">related to this issue here</a> that the user profile of the team city build agent does not allow getting a DirectX device. I have changed the Teamcity service, and TeamCity build agents to log on as user but still no luck. </p>
  
  <p>Any ideas? </p>