Hi VR
My first thought is that there must be something else going on in the form
to cause this problem. The reason being that the MSCOMM control should not
have been destroyed when the Closing event fires because it is possible to
cancel the form close from within the closing event. In that case, the
MSCOMM would have to be recreated somehow, and that clearly never happens.
Therefore, can you be sure that you are really shutting down the timer in
the Closing event? Set the debugger to break on all exceptions, and when the
exception occurs check the stack to see what had happened up to that point.
HTH
Charles
> Hi, I have an WinForm app that is described bellow:
>
[quoted text clipped - 33 lines]
> Thanks a lot
> Victor Reboucas
VR - 20 Sep 2005 18:37 GMT
Hi Charles,
I set the debugger to break on all exceptions and the result is the same,
that is, the timer elapses and tries to send a command to MSCOMM that does
not exist anymore.
I thought really interesting the fact that the timer and the ocx are in the
same user control (inside the form) and the instance for the ocx does not
exists anymore, but the timer more than exists, it's still running and
processing, something like I did not set tmr.Stop() and tmr.Enabled = False,
but I did.
By the way, after a lot of tests for use this ocx I realized that the
framework handles all the necessary clean-up in the interop layer
automatically, that is, I do not have to set comm.PortOpen = False, just
closing the form the port is automatically closed.
That means that I just turn off the timer, and did nothing about the ocx.
And this is what's getting me crazy: how can an object that I do nothing has
it's existence shorter than an object that I shut down explicitly?
Well, I'll get your clue about cancel the form's close event, make all the
shutdown process and call the close method explicitly by code.
thanks a lot,
Regards,
Victor Reboucas
> Hi VR
>
[quoted text clipped - 51 lines]
>> Thanks a lot
>> Victor Reboucas