That assertion seems to be because Windows is not returning a valid device context from a call to CreateCompatibleDC(). Since nothing in the stack back trace relates to your code we have no way of knowing what triggered this situation.