BUG: Error message when you call an OleDbDataReader object: System.InvalidCastException: QueryInterface for interface IRowset failed (313510)
The information in this article applies to:
- Microsoft ADO.NET (included with the .NET Framework)
- Microsoft Visual Studio .NET (2002), Professional Edition, when used with:
- Microsoft Visual C# .NET (2002)
This article was previously published under Q313510 SYMPTOMS 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.
Modification Type: | Minor | Last Reviewed: | 3/10/2006 |
---|
Keywords: | kbvs2002sp1sweep kbbug kberrmsg KB313510 |
---|
|