SharpDX.SimpleInitializer, an easy way of initializing SharpDX in your XAML projects

After working on some Windows Phone apps that required the usage of a DrawingSurface/DrawingSurfaceBackgroundGrid to perform Direct3D drawing, I have isolated some of the code in a standalone library for easily initialization of the Direct3D device, context and associated resources.

The library abstracts the initialization of Direct3D and transparently handles such cases as the control being resized (for example, a Windows Store application being snapped) and the device being lost or recreated (Windows Phone does this when sending the application to the foreground). The only dependency comes from SharpDX and it can be used in Windows Phone 8, Windows Phone 8.1 Silverlight, Windows Store 8.1 and Universal projects.

This is the workflow you should follow when using it:

  • When navigating to a page where the Direct3D drawing will be performed, instantiate a SharpDXContext object.
  • Subscribe to its DeviceReset and Render events to perform resource loading and drawing, respectively.
  • Call BindToControl passing the existing DrawingSurface, DrawingSurfaceBackgroundGrid, SwapChainPanel or SwapChainBackgroundPanel control.
  • The event Render will be raised whenever the control asks for a new frame, perform your drawing there using the D3DDevice and D3DContext properties.
  • When navigating away from the page, unsubscribe from the events and Dispose the SharpDXContext object.

You can download the library from NuGet, or take a look at the code on GitHub. Some sample projects that show how to properly manage the lifetime of the SharpDXContext object are available here.

Error 80072EFD on Nokia Lumia 800

A month or so ago I switched from my old HTC 7 Trophy to a brand new Nokia Lumia 800. Having Yoigo (a spanish mobile virtual network operator) I just inserted the SIM card, configured the APN and enabled roaming, thinking it would work the same way as in my old phone.

I got signal and everything started working like a charm, until some time later I couldn’t do anything that involved the data connection. Refreshing any email account displayed the dreaded 80072EFD error, and Twitter/Facebook/Internet Explorer said they couldn’t connect at all. Pretty annoying, since sometimes it started working when deactivating airplane mode or changing from one cellular network to another.

It looks like the only solution to this problem is to download the Nokia-exclusive Network Setup application. You can find it in the Nokia Collection section of the marketplace (it doesn’t appear at all throught the web marketplace, so you have to download it from your phone), and running it performs some kind of black magic that lets your data connection behave properly.