Delphi - 在 DLL 的 DataModule 中使用 TTable 时出错
我有一个运行良好的应用程序... 将其移植为 DLL 来实现。 我有一个数据模块,上面有我的数据库和 TTable 组件... 在设计模式下,数据库设置为活动状态。 表指向数据库,它们被设置为活动状态。 我可以右键单击表格,进入字段编辑器,然后查看所有列,所以我知道结构/属性设置得很好......
问题出在运行时...... 它在这条线上给了我一个 AV...
if MyDataModule.DB1.Connected = True then
ShowMessage('Active')
else
ShowMessage('Not Active');
我在网上看到了一些提示,需要做一些特殊的事情才能在 DLL 中使用数据模块,但我没有得到任何工作。
具体错误信息为:
模块“DocAssistCom.dll”中地址 06D4E22E 处的访问冲突读取地址 0000070'
I have an app that works fine...
Porting it to be implemented as a DLL.
I have a datamodule that has my Database and TTable components on it...
In Design mode, the Database is set to Active.
Tables point to the database, they are set to active.
I can right click on the tables, go the field editor, and see all the columns, so I know the structure/properties are set up fine....
The problem is at run time...
It gives me an AV on this line...
if MyDataModule.DB1.Connected = True then
ShowMessage('Active')
else
ShowMessage('Not Active');
I have seen hints on the web that there is something special that needs to be done to use a Datamodule inside a DLL, but I am not getting anything to work.
Specific error message is:
Access Violation at address 06D4E22E in module 'DocAssistCom.dll' Read of address 0000070'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该验证
MyDaModule
确实已创建,然后在尝试使用MyDataModule.DB1.Connected
之前也已创建MyDataModule.DB1
。但当您尝试使用它们时,它们可能尚未完全创建和准备好。
因此,我宁愿使用
OutputDebugstring
并在 IDE 中调试 DLL 来查看代码路径,而不是四处传播ShowMessage
调用...注意:
我不知道您正在使用哪个版本的 Delphi 和 Windows,但请注意 TTable 需要 BDE(现在已相当不推荐使用)...
You should verify that
MyDaModule
is indeed created, then thatMyDataModule.DB1
is created as well before even trying to useMyDataModule.DB1.Connected
.But they might still not be fully created and ready when you try to use them.
So, instead of spreading
ShowMessage
calls around, I would rather useOutputDebugstring
and debug the DLL in the IDE to see the code path...Note:
I don't know which versions of Delphi and Windows you are working with, but be aware that TTable requires the BDE (which is quite deprecated nowadays)...