Page 1 of 1
Invalid type cast in DLL repeat in version 5.70
Posted: Fri 24 Jul 2009 09:30
by alex D
Hello!
I use your VCL component MyDac from DLL (ะก++). Both Application and dll use borlndmm.dll for memory managment and dynamic standart RTL lib. After update IDE from RAD Studio 2007 to version RAD Studio2009 appear problem:
some simple request to mysql like 'select name from mytable;' throw exception EInvalidCast on call TMyQuery::Execute.
Table description `mytable`:
is InnoDB engine;
contain fields `id` - integer (primary key) and `name` - char(32);
use cp1251 (Russian charset).
In revision history you write:
5.50.0.35 11-Jun-08
* Fixed bug with 'Invalid class typecast' error inside dlls.
May be problem not fixed in version 5.70?
Also problem appear in Trial version 5.80.
Posted: Mon 27 Jul 2009 09:19
by Dimon
Please try to compose a small sample to demonstrate the problem and send it to dmitryg*devart*com.
Posted: Thu 30 Jul 2009 08:28
by alex D
I sent sample to email
Posted: Thu 30 Jul 2009 08:42
by Dimon
Thank you for information. We are investigating this problem. As soon as we solve the problem we will let you know.
Posted: Thu 30 Jul 2009 09:16
by Dimon
This problem is connected with work with dll. The point is that you create the TMyConnection class object in an application and use it with the TMyQuery object, created in dll. These methods use the "as" operator which returns invalid type cast error.
To solve this problem you should create TMyConnection object in dll.
Posted: Thu 30 Jul 2009 15:27
by alex D
Ok. I understand - RTTI mechanism is different for application and dll. That bug appear only with linking static MyDAC libs.
I solve the problem by use bpl dynamic linking.
Thanks for information!
Posted: Fri 21 May 2010 04:45
by Gigasoft
Dimon wrote:This problem is connected with work with dll. The point is that you create the TMyConnection class object in an application and use it with the TMyQuery object, created in dll. These methods use the "as" operator which returns invalid type cast error.
To solve this problem you should create TMyConnection object in dll.
Sorry to dig up an old thread, but I've just run into this problem myself.
The interesting thing is that it seems to have randomly cropped up. Until today this method (TMyConnection in App, Table/Query components in dll) has been working perfectly - in fact in all but one dll module it is still working.
Can you explain why it might have suddenly stopped working?
Posted: Fri 21 May 2010 06:45
by Dimon
To solve the problem try to use the TCustomMyConnection.AssignConnect method to assign the TMyConnection object created in dll to the TMyConnection object of application.
Also you can use the approach used in the MyDAC DLL demo.
Posted: Mon 24 May 2010 03:48
by Gigasoft
Thanks, AssignConnect works nicely, but doesn't allow me to do application wide monitoring using a TMySQLMonitor.
I've solved the problem by adding MyDAC70 and DAC70 to the runtime packages list - I actually thought I'd already done this, but apparently not.