Step through the code and check what object is null when the "de referencia a Objeto no establecido" exception is thrown.
E.g. is maybe "dc" null after GetDC..? The stack trace for the exception may also give a hint...
Microsoft is conducting an online survey to understand your opinion of the Msdn Web site. If you choose to participate, the online survey will be presented to you when you leave the Msdn Web site.
Would you like to participate?