Invalid Pointer exceptions when using Win2D

Chances are if you are using Win2D in a complex app, you may have seen it crash sometimes with an unhandled exception with HResult 0x80004003 and a not very descriptive message containing only the phrase Invalid pointer.

If this is the case, take a second look at all your CanvasCreateResourcesEventArgs.TrackAsyncAction calls – because, while you may think this is a threading problem, the cause is far easier to solve: you are accessing a null object/property instead. Somehow Win2D is throwing an Exception with that error message instead of a NullReferenceException.

Leave a Reply