Page 1 of 1

[Resolved] TOraSQLMonitor & Thread

Posted: Tue 03 Feb 2009 15:35
by yousky
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

Posted: Tue 03 Feb 2009 15:44
by yousky
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 :-(

Posted: Wed 11 Feb 2009 12:49
by Plash
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.

Posted: Tue 17 Feb 2009 10:31
by yousky
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