Re:App compiles fine but exception on start, why?
"Bo Berglund" <bo.bergl...@telia.com> skrev i melding
news:3ce060d3.1169459203@news.telia.net...
Quote
> (Posted to the wrong group so here it is again)
> I have developed a component to handle some security issues. This
> component contains among other stuff a timer that is created in
> component.Create wher I also set interval to 0 and enabled to false.
> If I put this component on a form and compile the application all is
> fine, but when I try to start this minimalistic app then there is
> immediately a very strange exception:
> "Exception EClassNotFound in module Project1.exe at 0000CA2A
> Class TTimer not found."
I believe the problem may be that if you don't use TTimer in your
application, the class won't be registered. And - and here is the strange
point - that you have created your component so that a TTimer - property is
to be read, either when loading your component *or* as a result ogf your
component creating a TTimer object that is streamed with the form. The
workaround is to do a RegisterClass(TTimer);. I wouldn't do that if I
weren't sure about what the trouble was...
Quote
> If I step through the start sequence I get to the Create and the timer
> property setting and there are no problems. Then after leaving Create
> I get to the setters for the component properties and there I again
> meet the timer and it is set successfully. Then at the very end
> (stepping next on the 'end' line) there is this exception.
> Where is it coming from and what can be done about it?
> Final note:
> If I try to remove the component from the form then Delphi locks up
> completely! I cannot even get to Task Manager easily to kill it off.
> I am running Delphi 5 pro on a Win XP-Pro system.
Creating a component that can actually be removed without bombing is one of
the more challenging tasks in delphi. ;-) The only tougher one is to make it
survive deleting a *referenced component*.
- You'll have to read your code again, asking yourself: "What about this
reference, will it allways be valid ?"
The "classic" error is when 2 components reference each other, and these
references are not "enforced" by notifications (see TComponent's methods:
FreeNotifier / Notification).
--
Bj?rge S?ther
bjorge@hahaha_itte.no