TMS WEB Core自定义非可视组件编译报错:未找到TMSWebPlatform
问题:自定义TMS WEB Core非可视组件编译报错“identifier not found 'TMSWebPlatform'”
我按照TMS WEB Core的自定义组件开发文档构建非可视组件,已成功编译并安装BPL到Delphi IDE,组件能在面板找到并放到窗体,但编译Web应用时出现错误:
[Error] MyTestCustomComponents.pas(9): identifier not found "TMSWebPlatform"
我的组件单元代码如下:
unit MyTestCustomComponents; interface uses System.SysUtils, System.Classes, WebLib.Controls; type [ComponentPlatforms(TMSWebPlatform)] TMyWebComponent = class(TComponent) private { Private declarations } protected { Protected declarations } public { Public declarations } published { Published declarations } end; procedure Register; implementation procedure Register; begin RegisterComponents('My Web Test Components', [TMyWebComponent]); end; end.
解决方案
- 问题根源:
TMSWebPlatform常量并不在WebLib.Controls单元中,而是定义在WebLib.Constants单元里,你的uses列表缺少这个单元引用。 - 修复步骤:
- 在interface段的uses列表中添加
WebLib.Constants:uses System.SysUtils, System.Classes, WebLib.Controls, WebLib.Constants; - 重新编译组件包并安装到IDE,再重新编译Web应用即可解决该错误。
- 在interface段的uses列表中添加
额外建议:对于TMS WEB Core的非可视组件,推荐直接继承TWebCustomComponent(位于WebLib.Controls单元),它是专门为Web环境设计的非可视组件基类,比直接继承TComponent更适配框架特性。
内容的提问来源于stack exchange,提问作者Shaun Roselt
相关产品推荐
相关产品推荐

