none
Value Dispose() cannot be called while doing CreateHandle().

    Question

  • Hi,

    While am closing a form,  Some times I am getting following exception

     

    Value Dispose() cannot be called while doing CreateHandle().

     

    I get this error at Dispose() method.

     

    Can you suggest me, to avoid this error.

     

     

     

     

    Tuesday, October 12, 2010 9:28 AM

All replies

  • I found same problem when i use form X button on forms right hand corner.

    Error:
    "An unhandled exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll
    Additional information: Value Dispose() cannot be called while doing CreateHandle()."


    I try this solution and it works
    I found 'form' property of "Cancel Button"  which assign as 'None'.

    I add new exit button and do exitbutton_click event In that i call function as
    'Close();'

    this exitbutton i link to 'form property Cancel Button'

    It works well when i click on form X button.

    Tuesday, June 05, 2012 3:40 AM