c#操作Vertica数据库时,打开多个页面偶尔会出现这个错误,无法访问已关闭的流
具体的代码位置是
da.Fill(ds);
da是VerticaDataAdapter
未处理System.ObjectDisposedException
HResult=-2146232798
Message=无法访问已关闭的流。
ObjectName=""
Source=mscorlib
StackTrace:
在 System.IO.__Error.StreamIsClosed()
在 System.IO.BufferedStream.Read(Byte[] array, Int32 offset, Int32 count)
在 Vertica.Data.Internal.IO.VStream.ReceiveIntegerR(Int32 siz)
在 Vertica.Data.Internal.IO.RowData.readNextColumn()
在 Vertica.Data.Internal.IO.RowData.readAll()
在 Vertica.Data.Internal.IO.DataRowResponseMessage.FinishReadRow()
在 Vertica.Data.Internal.IO.ProtocolStream.ReadMessage()
在 Vertica.Data.Internal.DataEngine.VResultSet.FetchChunk(Boolean clearExistingRowCache)
在 Vertica.Data.Internal.DataEngine.VResultSet.MoveToNextRow()
在 Vertica.Data.Internal.DataEngine.VResultSet.CloseCursor()
在 Vertica.Data.Internal.ADO.Net.SDataReader.Close()
在 Vertica.Data.Internal.ADO.Net.SDataReader.Dispose(Boolean disposing)
在 System.Data.Common.DbDataReader.Dispose()
在 System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
在 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
在 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
在 NHibernateVertica.VerticaDataHelper.FillDataTable(VerticaDataAdapter da, DataSet& ds, Boolean& isDone) 位置 F:\code\com.km.site\NHibernateVertica\VerticaDataHelper.cs:行号 224
在 NHibernateVertica.VerticaDataHelper.<>c__DisplayClass12_0.b__0() 位置 F:\code\com.km.site\NHibernateVertica\VerticaDataHelper.cs:行号 160
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
InnerException:
检查你的代码,你是否不正确使用了 close 或者 dispose/using ,导致访问的流对象已经关闭了。