none
Critical Bug in Access Database Engine 2016 for Windows 10 x86 RRS feed

  • Question

  • My application is using access database file 2010 and it works perfectly on Win 7x 86

    When this application runs on Windows 10 x86 it must use AccessDatabaseEngine 2016 x86. However, the routine listed below crashes my application without a trace.

    I checked Event Log and I see that the problem is at OleDbConnection.Open routine.  This function must be called in the main GUI thread of Windows application.  As expected, my application can use this routine in the main GUI thread without a problem. But as soon as it is called in a thread spawn from main GUI thread of my application then it crashes immediately.

     I believe that this is a bug with Access Database Engine 2016 for Windows 10 x86.

    Thanks

                Using objConnection As New OleDbConnection(m_strConnectionString)

                    objConnection.Open()

                    Using cmd As OleDbCommand = objConnection.CreateCommand


                        Dim strQuery As String
                        strQuery = String.Format("DELETE FROM {0}", m_strLogTable)
                        cmd.CommandText = strQuery
                        cmd.ExecuteNonQuery()
                    End Using
                End Using

    Event Log:

    Faulting module name: mso40uiwin32client.dll, version: 16.0.4519.1000, time stamp: 0x58bed810
    Exception code: 0xc0000005
    Fault offset: 0x00166226
    Faulting process id: 0xbcc

    Framework Version: v4.0.30319
    Description: The process was terminated due to an unhandled exception.
    Exception Info: System.AccessViolationException
       at System.Data.OleDb.DataSourceWrapper.InitializeAndCreateSession(System.Data.OleDb.OleDbConnectionString, System.Data.OleDb.SessionWrapper ByRef)
       at System.Data.OleDb.OleDbConnectionInternal..ctor(System.Data.OleDb.OleDbConnectionString, System.Data.OleDb.OleDbConnection)
       at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(System.Data.Common.DbConnectionOptions, System.Data.Common.DbConnectionPoolKey, System.Object, System.Data.ProviderBase.DbConnectionPool, System.Data.Common.DbConnection)
       at System.Data.ProviderBase.DbConnectionFactory.CreateConnection(System.Data.Common.DbConnectionOptions, System.Data.Common.DbConnectionPoolKey, System.Object, System.Data.ProviderBase.DbConnectionPool, System.Data.Common.DbConnection, System.Data.Common.DbConnectionOptions)
       at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(System.Data.Common.DbConnection, System.Data.ProviderBase.DbConnectionPoolGroup, System.Data.Common.DbConnectionOptions)
       at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(System.Data.Common.DbConnection, System.Threading.Tasks.TaskCompletionSource`1<System.Data.ProviderBase.DbConnectionInternal>, System.Data.Common.DbConnectionOptions, System.Data.ProviderBase.DbConnectionInternal, System.Data.ProviderBase.DbConnectionInternal ByRef)
       at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(System.Data.Common.DbConnection, System.Data.ProviderBase.DbConnectionFactory, System.Threading.Tasks.TaskCompletionSource`1<System.Data.ProviderBase.DbConnectionInternal>, System.Data.Common.DbConnectionOptions)
       at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(System.Data.Common.DbConnection, System.Data.ProviderBase.DbConnectionFactory, System.Threading.Tasks.TaskCompletionSource`1<System.Data.ProviderBase.DbConnectionInternal>, System.Data.Common.DbConnectionOptions)
       at System.Data.ProviderBase.DbConnectionInternal.OpenConnection(System.Data.Common.DbConnection, System.Data.ProviderBase.DbConnectionFactory)
       at System.Data.OleDb.OleDbConnection.Open()
      

    Friday, July 27, 2018 12:51 PM

Answers

  • H Almahmood,

    I did update my PC 

    I do think it is related to the MS Access database file itself.

    My application is installed on the customer machine that only requires MS Access Database Engine 2016 x86.

    To prove this out, I remove the database before attempting to create a new connection again inside a thread then my app just crashed. I believe that the OleDbConnection.Open method is crashed before it detects the missing database file.

    I test the same code running in the same thread then it is all OK. 


    Friday, August 3, 2018 6:21 PM

All replies

  • Hi,

    Win 7 is out of time. If you want to keep it, it is not surprising that you experience problems. And it is not reasonable to say that there is an Access problem.

    Everything changes, also in technology. To improve things you have to be able to change. If you stick to old things, you can not move. Both in all things in life and in technology. Give up the old, because where the old is maintained, the new can not be there. Life is dynamic, not static.


    What I mean is that I think you should not start from a database that operated under Win 7, but under Win 10.
    Saturday, July 28, 2018 1:50 PM
  • Hello thichcoiphim2,

    What's the detail building number of your Office? What's the version of your windows?

    What's the m_strConnectionString? Have you checked any other connecting string?

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, July 30, 2018 1:26 AM
  • Terry, 

    Here is the information about MS Access 2010

    Version: 14.0.7161.5001 SP2 MSO 14.0.7194.5000

    MICROSOFT OFFICE PROFESSIONAL PLUS 2010

      <connectionStrings>
        <add name="OMCS.My.MySettings.dataConnectionString"
          connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Data\data.accdb;Persist Security Info=True"
          providerName="System.Data.OleDb" />
      </connectionStrings>


    I do not check other connection string because I believe that it should work the way it is. Everything is working correctly with the connection object created in the main GUI thread. When I need to close and create the connection object again in other threads then it will crash my app.

    I believe that anyone can try this out easily by opening a connection in a thread and it will crash immediately.

    Thanks


    Monday, July 30, 2018 12:16 PM
  • Hello thichcoihim2,

    Currently, I'm trying to create a test environment with Window 10 X86 which will spend me some time. Your patience will be greatly appreciated.

    Besides, since your Office is not latest version, I would suggest you update your office to latest version for testing. And for avoiding misunderstanding, I would suggest you share the detail code how do you call the code in a thread spawn.

    Thanks for understanding,

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, August 1, 2018 5:52 AM
  • So this code is vb.net

    Have you forced the project to be x68 (x32 bits) ?

    I would suggest that you remove, and then re-add any referances you have in your .net project. And as noted, force the procject to be x86 (x32), and then do a project clean, and a re-build.

    Rregardless, I see little if any reason why your code would not work, but I would do your build on a x64 bit machine, since "many" of your reference paths used in your .net project will have their location changed.

    I would:

    remove, and then re-add your references (and do this on a x64 machine with access x32)

    I would then ensure that the project "cpu" is forced to x32.

    Regards,

    Albert D. Kallal (Access MVP, 2003-2017)

    Edmonton, Alberta Canada


    Wednesday, August 1, 2018 6:05 PM
  • Hi Terry, 

    After a few tests, I found out that if the connection object is created /re-created in the same thread then it is OK, otherwise it will crash my application.

    I have a class called CDatabase that provides methods for compacting the database daily.

    The database object is created on main GUI thread. The monitoring thread is responsible for compacting the database daily.  Due to the requirement of compacting the access database, all connections must be closed.  As a result, we need to close the connection on the CDatabase object and re-created after we finish the task. At the time, the open method on the OleDbConnection object is called it will crash my application. 

    The same code works perfectly on Win7/WinXP x86 but not on Windows 10 x86.  

    *******************************************************

    On the test application,  I have a test routine that creates the CDatabase object and starts a thread which calls the CompactResetDatabase method from the created CDatabase object on the main GUI thread.

    My application will crash when it tries to re-create a new connection object in the spawn thread.

           

    Here is the code:

    Public sub TestDatabase()

       Try
                m_objDatabase = New CDataBase(My.Settings.dataConnectionString)
                m_objDatabase.Connect()

                MsgBox("Connected")

            Dim t As System.Threading.Thread
            t = New System.Threading.Thread(AddressOf ThreadProc)
            t.Start()

            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try

    End Sub

        Private Sub ThreadProc()

            m_objDatabase.CompactResetDatabase()

            MsgBox("Thread stops")

        End Sub

    Public Class CDataBase
        Private Shared m_strConnectionString As String
        Protected Shared m_dbConnection As OleDbConnection
        Protected Shared m_dbCommand As OleDbCommand

        Public Sub New(ByVal strConnectionString As String)
            m_strConnectionString = strConnectionString
        End Sub

    Public Sub Connect()

                    If m_dbConnection IsNot Nothing Then
                        m_dbCommand.Dispose()
                        m_dbCommand = Nothing

                        m_dbConnection.Close()
                        m_dbConnection.Dispose()
                        m_dbConnection = Nothing
                    End If

                    m_dbConnection = New OleDbConnection
                    m_dbConnection.ConnectionString = m_strConnectionString
                    m_dbCommand = New OleDbCommand
                    m_dbCommand.Connection = m_dbConnection

                    m_dbConnection.Open()

        End Sub

        Public Sub DisConnect()

                    If m_dbCommand IsNot Nothing Then
                        m_dbCommand.Dispose()
                        m_dbCommand = Nothing
                    End If

                    If m_dbConnection IsNot Nothing Then
                        m_dbConnection.Close()
                        m_dbConnection.Dispose()
                        m_dbConnection = Nothing
                    End If

        End Sub

        Public Function IsConnected() As Boolean
            If m_dbConnection Is Nothing Then Return False
            If m_dbConnection.State = Data.ConnectionState.Open Then Return True
        End Function

     Public Sub CompactResetDatabase()

                Dim strPath As String = ""
                Dim blnDelete As Boolean = False
                Dim blnBackup As Boolean = False

                Try
                    If IsConnected() Then
                        DisConnect()
                    End If

                    Try
                         CompactDataBase(strPath, m_strDataBase, m_strNewDataBase, m_strPassword)
                    Catch ex As Exception
                        Throw New ApplicationException(String.Format("Failed to compact database file at location {0}{1}. Error {2}", strPath + "\" + m_strDataBase, vbCrLf, ex.Message))

                    End Try

                Catch ex As Exception
                    Throw New ApplicationException(String.Format("Failed to compact database file at location {0}{1}. Error {2}", strPath + "\" + m_strDataBase, vbCrLf, ex.Message))
                Finally
                    'connect to the database again after finish compacting database file
                    Connect()  ' CRASH WHEN CALLING THIS METHOD due to the creation of a new connection in a different thread
                End Try

        End Sub

        Protected Sub CompactDatabase(strPath As String, strDataBase As String, strNewDataBase As String, strPassword As String)

                Dim dbEngine As Microsoft.Office.Interop.Access.Dao.DBEngine

                Try
                    dbEngine = New Microsoft.Office.Interop.Access.Dao.DBEngine

                    dbEngine.CompactDatabase(strPath + "\" + m_strDataBase, strPath + "\" + m_strNewDataBase, Nothing, Nothing, ";pwd=" & m_strPassword)

                Catch ex As Exception
                    Throw New ApplicationException(String.Format("Failed to compact database file at location {0}{1}. Error {2}", strPath + "\" + m_strDataBase, vbCrLf, ex.Message))
                Finally

                End Try

        End Sub





    Thursday, August 2, 2018 6:09 PM
  • For the time being, I have to raise an event to compact the database from the main GUI thread that uses exactly the same code.

    My question is why OleDbConnection does behave like this on Windows 10 x86

    Thanks

    Thursday, August 2, 2018 10:14 PM
  • Hi thichcoiphim2,

    Please try the following methods and see the problem resolves:

    1.See if there is any Office Update is pending. If so, please update your Office to the newest version.
    2.Use Office Online repair.
    3.Install Office Configuration Analyzer Tool (OffCAT) from the following article: https://support.microsoft.com/kb/2812744
     
    Please let us know the following information:
    1.Do the other Office program crashes?
    2.Does the crash happen on all the databases or this specific database?

    Friday, August 3, 2018 1:20 PM
  • H Almahmood,

    I did update my PC 

    I do think it is related to the MS Access database file itself.

    My application is installed on the customer machine that only requires MS Access Database Engine 2016 x86.

    To prove this out, I remove the database before attempting to create a new connection again inside a thread then my app just crashed. I believe that the OleDbConnection.Open method is crashed before it detects the missing database file.

    I test the same code running in the same thread then it is all OK. 


    Friday, August 3, 2018 6:21 PM
  • Hi thichcoiphim2,

    Have you found a solution? I'm in the same situation. I installed Access 2010 Database engine and set Ole db Sevices = -1 in the connection string but it doesn't work either, after a minute of last query to the DB raises an error in the  Event Viewer: 

    Id. del programa componente: SC.Pool 1 1
    Nombre del método: IDispenserDriver::CreateResource
    Nombre del proceso: XXXX
    Excepción: c0000005

    Thanks

    Monday, November 18, 2019 10:35 AM
  • If you got the same issue as I reported then you need to ensure that your code must be called in the same thread if not it will throw an exception.
    Monday, November 18, 2019 11:17 PM