none
Memory corruption in .net managed code.. RRS feed

  • Question

  • In a desktop application developed by my organisation, the below error is logged and the application suddenly crashed...

    Display Message       : Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

    Error Message         :    at System.Data.Common.SafeNativeMethods.CoTaskMemFree(IntPtr handle)

       at System.Data.OleDb.RowBinding.FreeCoTaskMem(IntPtr buffer, Int32 valueOffset)

       at System.Data.OleDb.RowBinding.ResetValues(IntPtr buffer, Object iaccessor)

       at System.Data.OleDb.RowBinding.ResetValues()

       at System.Data.OleDb.RowBinding.Dispose()

       at System.Data.OleDb.OleDbDataReader.DisposeManagedRowset()

       at System.Data.OleDb.OleDbDataReader.DisposeOpenResults()

       at System.Data.OleDb.OleDbDataReader.Close()

       at System.Data.Common.DbDataReader.Dispose(Boolean disposing)

       at System.Data.Common.DbDataReader.Dispose()

       at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)

       at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)

       at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)

       at BNCSSecuritiesTrading.BNCSBusinessLayer.BNCSData.OleDbDataAccess.GetDataSet(String pSQLQuery, DataSet& pResult, String pDatatableName)

       at BNCSSecuritiesTrading.BNCSBusinessLayer.BNCSCommon.clsFunction.CommonDatabaseQuery(String pstrQuery, String ptableName, EnumGetConnectionString pConnectionStringMode, EnumQueryOperationalMode pQueryMode)

       at BNCSSecuritiesTrading.BNCSBusinessLayer.BNCSCommon.clsFunction.UpdateGlobalRelationalDatatableForClient(EnumSearchCriteria penumSearchCriteria, String pstrSearchValue)

       at BNCSSecuritiesTrading.BNCSBusinessLayer.BNCSCommon.clsFunction.GetClientDetails(EnumSearchCriteria penumSearchCriteria, String pstrSearchValue, String pstrExchangeID)

       at BNCSSecuritiesTrading.BNCSBusinessLayer.BNCSCommon.clsFunction.GetClientData(EnumSearchCriteria penumSearchCriteria, String pstrExchangeID, TextBoxEx& ptxtClientId, ComboBoxEx& pcboPortfolioId, TextBoxEx& ptxtBankAccNo, TextBoxEx& ptxtExchClientId, TextBoxEx& ptxtNIN, TextBoxEx& ptxtClientName, Label& plblIdenType, Boolean& pblnSWAP, Boolean& pblnMargin, ListBox& plstClientList, ComboBoxEx& pcboProduct, ComboBoxEx& pcboCorrBrok)

    I know that the there are no Memory corrupt errors in .net managed code....but the below error has occurred at the System.data level.....please check and advise me on how to resolve this problem...


    • Edited by N T Raju Sunday, April 20, 2014 5:18 AM
    Sunday, April 20, 2014 5:15 AM

Answers

  • When query a database you only get one datatable.  You don't need a DataSet. 
    With the adapter you can either fill a DataTable or DataSet.  When you fill the DataSet you can either use the name of the data table or the index number of the table.  I don't noramally use DataSet with a query (only with XML objects).

    DataTable table = new DataTable();

    adapter.fill(table);


    jdweng

    Sunday, April 20, 2014 11:43 AM

All replies

  • this could be due to many factors, try searching online + applying few tips as suggested. I also think there is a bug in the application itself.

    see this thread as an example discussion on this issue.

    hope this helps!

    Sunday, April 20, 2014 5:28 AM
  • Most likely the name of the datatable inside the dataset doesn't exist or you did use "new" when either creating the dataset or datatable.  You will get the error message " Memory corrupt errors " when either the datatable or dataset is null.  You may also get this error if the number of columns of the datatable is larger than the number of fields in the database.


    jdweng

    Sunday, April 20, 2014 6:28 AM
  • Thank you jdweng..for your reply..

    I would like to have a question :

    Is a name of the datatable is required while filling dataset from the database using OleDbDataAdapter ?

    and I have used the keyword"new" while creating the dataset for every database query..

    and the third one..I did not create any columns in the datatable of the dataset before filling it using the OleDbDataAdapter..

    Thank you..

    Sunday, April 20, 2014 6:44 AM
  • When query a database you only get one datatable.  You don't need a DataSet. 
    With the adapter you can either fill a DataTable or DataSet.  When you fill the DataSet you can either use the name of the data table or the index number of the table.  I don't noramally use DataSet with a query (only with XML objects).

    DataTable table = new DataTable();

    adapter.fill(table);


    jdweng

    Sunday, April 20, 2014 11:43 AM