请教EClassNotFound异常问题,谢谢帮忙!
Form上面有一个组件TJTreeView,编译成功,运行时出现EClassNotFound异常,就是说程序并没有注册该类RegisterClass,我重新建立一个程序,放一个TJTreeView,一切正常。就是原来的程序,去掉该组件就行,放上就不行,怎么重新编译都不行,bcb帮助说可能是窗口上有组件,但是在声明中删除了定义。但是我的定义等等什么都有,就是会异常。
//.cpp
#pragma link "JTreeView"
//.h
#inlcude "JTreeView.h"
__published:
TJTreeView *JTreeView1;
问题点数:100、回复次数:5Top
1 楼TangSe(void_onering)回复于 2003-12-03 12:41:39 得分 0
When I add a TPlotToolBar to a form, connect it to a Plot and a PlotImageList, it looks and works fine. However, when I run the program, it crashes with a message "EClassNotFound: Class TToolButton not found".
There is a very subtle bug in TPlotToolBar that causes an exception when the form data is streamed. This is being worked on, but for the moment, the best thing to do is not assign the Plot property of TPlotToolBar in the IDE, but set it in the FormCreate method of the Form that contains the offending PlotToolBar.
Top
2 楼TangSe(void_onering)回复于 2003-12-03 12:44:12 得分 0
看来上面的也是这个问题,但是我并没有Assign anything!竟然怎么样都不行,我的是在其他所有程序中都可以正常使用TJTreeView组件而没有任何错误,但是就是有一个程序中不行,老是EClassNotFound。Top
3 楼TangSe(void_onering)回复于 2003-12-03 12:46:35 得分 0
當你把 form 上面的元件宣告移到 private 區域時,可以通過編譯,但是執行時會出現錯誤:
Exception EClassNotFound in module vcl50.bpl at XXXXXXXX.
Class XXX not found.
此問題有個辦法可以解決,就是在 initialization 區段手動去註冊這個類別,現在假設我把 Button1 的宣告移到了 private 區域,只要加入以下程式碼,程式就可以正確執行了:
initialization
RegisterClass(TButton);
然後,費了一番功夫之後,卻只是為了將元件隱藏在 private 區域,這麼做並不實際,這裡提出的方法只是供讀者參考而已。
Top
4 楼huoniao1976(火鸟1976)回复于 2004-01-10 08:41:47 得分 10
楼上的兄弟是台湾地?Top
5 楼invalid(空心菜(Python是个好东东,大家多用用!))回复于 2004-01-10 10:37:47 得分 90
这个问题我碰到过。当时是TEdit这个类找不到。
新建立一个工程,把原工程中的单元文件添加到新工程中,然后再编译试试。Top




