[Resolved] TOraSQLMonitor & Thread

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
yousky
Posts: 5
Joined: Mon 02 Feb 2009 16:34

[Resolved] TOraSQLMonitor & Thread

Post by yousky » Tue 03 Feb 2009 15:35

Hi Devart Team,

I have Delphi 2006 .NET with ODAC Components v5.80.0.40.

When i connect my TOraSession from a thread the application crash with exception:

System.InvalidCastException
'QueryInterface for interface CoreLab.Dac.IDBMonitor failed.'

Without a thread it works great.

thanks
Greg
Last edited by yousky on Tue 17 Feb 2009 10:33, edited 1 time in total.

yousky
Posts: 5
Joined: Mon 02 Feb 2009 16:34

Post by yousky » Tue 03 Feb 2009 15:44

I found a wait to avoid that problem by desactivate temporary the SQLMonitor during Session opening and reactivate it just after session opened.

After testing, it working not, during sql request in my thread, if I open a new request in my waiting part of code in my application, I still have this exception :-(

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Wed 11 Feb 2009 12:49

ODAC passes information to DBMonitor using a COM object. .Net applications have STAThread attribute by default. This attribute does not allow using the COM object from other threads. If you remove this attribute, the TOraSQLMonitor component works from any thread.

To remove the attribute, you need to open the project source and find [STAThread] line before 'begin' line.

yousky
Posts: 5
Joined: Mon 02 Feb 2009 16:34

Post by yousky » Tue 17 Feb 2009 10:31

Thanks Plash,

I removed the [STAThread] directive from the DPR of my Delphi.Net project and it seems to work great now.

Good job.
Greg

Post Reply