|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
UserControl TerrorsI have a UserControl that subclasses to trap messages. If my program ends unexpectedly, (i.e., because of an error, the "end" keyword, or the stop button,) the VB IDE crashes and shut down entirely. When I reload the project in VB, I get a message telling me to check my min form's ..Log file. When I do, it contains the following error concerning my UserControl class: "Class [classname] in control [controlname] is not a loaded control class." According to the ever brilliant MSDN: "This message appears if Visual Basic finds a class name it doesnt recognize." All my code appears to be perfectly intact, yet VB won't load my Usercontrol. I've tried restarting, recompiling the user control, and copying all of my code into a new project (big hassel.) That last option *sort of* works, but it's messy and lossy as far as properties go. Any ideas on what do I do about this? -Joel
Show quote
Hide quote
> I have a UserControl that subclasses to trap messages. If my program I don't do UserControls myself, so I can't address that aspect of the> ends unexpectedly, (i.e., because of an error, the "end" keyword, or the > stop button,) the VB IDE crashes and shut down entirely. When I reload > the project in VB, I get a message telling me to check my min form's > .Log file. When I do, it contains the following error concerning my > UserControl class: > > "Class [classname] in control [controlname] is not a loaded control class." > > According to the ever brilliant MSDN: > "This message appears if Visual Basic finds a class name it doesnt > recognize." > > All my code appears to be perfectly intact, yet VB won't load my > Usercontrol. I've tried restarting, recompiling the user control, and > copying all of my code into a new project (big hassel.) That last > option *sort of* works, but it's messy and lossy as far as properties go. > > Any ideas on what do I do about this? problem. However, errors occurring during subclassing while running in the IDE are a known problem. You can search the Google's Group section for lots of threads about this. This one message may be of help though... http://groups-beta.google.com/group/microsoft.public.vb.general.discussion/browse_frm/thread/6ecfdecd075df4a1/ae0e5b2238c13dba?q=subclass+error+crash+group:*.vb*&rnum=2&hl=en#ae0e5b2238c13dba Now... take out that End statement you indicate is in your program. Using it is a disaster waiting to happen. From an old post of mine... Never, never, never, never, ever use the End statement to terminate your program. End should ***NEVER*** be used in VB. When you start writing more complex code, you will find that in certain situations, VB needs to do some cleaning up (and you need to help it). You can go to this Google newsgroup link http://groups.google.co.uk/advanced_group_search?num=100&as_scoring=d&as_ugroup=*.vb* and look up the exact word "vb" and the exact phrase "end statement" (leave off the quotes in both of these) to find the many ways people have explained the why and what of not using the End statement. Suffice it to say that the End statement stops your program in the same way running into a brick wall stops your car... immediately. You don't get a chance to coast to a stop and turn your key to the off position, open the door and exit the vehicle. The same thing happens with the End statement... BOOM!, everything stops dead in its tracks right then and there and the program ends. The moral is... NEVER, NEVER, NEVER use the End statement in your program! (And, in the same way, using that "solid square" icon on VB's Toolbar, or clicking End in the Run menu, to stop your project during development is the identical equivalent of executing an End statement in code... you shouldn't do that either.) Consider this... From the VB Help Files: "More About Forms" "The End statement ends an application immediately: no code after the End statement is executed, and no further events occur. In particular, Visual Basic will not execute the QueryUnload, Unload or Terminate event procedures for any forms. Object references will be freed, but if you have defined your own classes, Visual Basic will not execute the Terminate events of objects created from your classes." "In addition to the End statement, the Stop statement halts an application. However, you should use the Stop statement only while debugging, because it does not free references to objects." Rick - MVP Rick Rothstein wrote:
> I don't do UserControls myself, so I can't address that aspect of the Thanks Rick! I'll check it out right now.> problem. However, errors occurring during subclassing while running in > the IDE are a known problem. You can search the Google's Group section > for lots of threads about this. This one message may be of help > though... > > http://groups-beta.google.com/group/microsoft.public.vb.general.discussion/browse_frm/thread/6ecfdecd075df4a1/ae0e5b2238c13dba?q=subclass+error+crash+group:*.vb*&rnum=2&hl=en#ae0e5b2238c13dba > > Now... take out that End statement you indicate is in your program. FYI- I don't use end statements - I close up by unloading all my forms > Using it is a disaster waiting to happen. > and other objects - just like you guys taught me since I joined this newsgroups when I was 13. I was just noting that "End" did the same thing as an error. I'm really grateful for your fast response! -Joel hi Joel,
Take some time to read Steve McMahon's article: "subclassing without tears". http://www.vbaccelerator.com/home/VB/Code/Libraries/Subclassing/SSubTimer/article.asp It may encourage you to use Steve's execllent sSubTmr.dll control for your subclassing in the future. cheers, jw Joel Whitehouse wrote: Show quoteHide quote > Hello All, > > I have a UserControl that subclasses to trap messages. If my program > ends unexpectedly, (i.e., because of an error, the "end" keyword, or the > stop button,) the VB IDE crashes and shut down entirely. When I reload > the project in VB, I get a message telling me to check my min form's > .Log file. When I do, it contains the following error concerning my > UserControl class: > > "Class [classname] in control [controlname] is not a loaded control class." > > According to the ever brilliant MSDN: > "This message appears if Visual Basic finds a class name it doesnt > recognize." > > All my code appears to be perfectly intact, yet VB won't load my > Usercontrol. I've tried restarting, recompiling the user control, and > copying all of my code into a new project (big hassel.) That last > option *sort of* works, but it's messy and lossy as far as properties go. > > Any ideas on what do I do about this? > > -Joel |
|||||||||||||||||||||||