Article ID: 313510 - Last Review: March 10, 2006 - Revision: 2.3 BUG: Error message when you call an OleDbDataReader object: System.InvalidCastException: QueryInterface for interface IRowset failed
This article was previously published under Q313510 On This PageSYMPTOMS When you call an OleDbDataReader object that invokes the Read method from a different single-threaded apartment (STA) thread
than the object was created in, you receive the following exception:
System.InvalidOperationException: The
OleDbDataReader.Read must be used from the same thread on which is was created
if that thread's ApartmentState was not ApartmentState.MTA
CAUSE This behavior occurs because the component that implements
IRowset does not aggregate the free-threaded marshaller, even though it is
marked with a threading model of both. This causes OLE32 to use its own
IMarshal, which requires either a typelib or a proxy and stub to be registered
for the interface. RESOLUTION To work around this issue, make sure that you use an OleDB object only from the STA thread that it is created in, or from
any multithreaded apartment (MTA) if it was created on an MTA. STATUSMicrosoft has confirmed that this is a bug in the Microsoft
products that are listed at the beginning of this article.
MORE INFORMATIONSteps to Reproduce the Problem
| Other Resources Other Support Sites
CommunityGet Help NowArticle Translations
|






Windows Live
Facebook
Twitter
Linkedin
Digg it
Yahoo
Delicious
StumbleUpon
Yammer
Reddit
Technorati
FriendFeed
Email
Back to the top
