none
Excel 2016 AccessViolation in ACEOLEDB.DLL after creating/opening/closing a oledbconnection multiple times RRS feed

  • Question

  • We get an AccessViolation Exception if we try to insert data into several Excel Sheets using .NET and the ACE OLEDB driver (32Bit, Office 2016).

    The error occurs after we repeat the following procedure several times:

    - Create the OleDbConnection
    - Open the connection
    - Select and/or insert some data
    - Close the connection

    The same code works in Office 2013 without problems.

    Stacktrace:

    Eine Ausnahme (erste Chance) des Typs "System.AccessViolationException" ist in System.Data.dll aufgetreten.

     

                    ntdll.dll!_NtWaitForSingleObject@12()  + 0xc Bytes       

                   KernelBase.dll!76eee201()         

                    [Unten angegebene Rahmen sind möglicherweise nicht korrekt und/oder fehlen, keine Symbole geladen für KernelBase.dll]

                   ntdll.dll!ExecuteHandler2@20()  + 0x26 Bytes  

                   ntdll.dll!ExecuteHandler@20()  + 0x24 Bytes     

                   ntdll.dll!_KiUserExceptionDispatcher@8()  + 0xf Bytes  

                   Mso40UIwin32client.dll!6fcc5a26()        

                    vcruntime140.dll!_CallSettingFrame(unsigned long funclet, unsigned long pRN, unsigned long dwInCode)  Zeile 64           Asm

                   vcruntime140.dll!_CallCatchBlock2(EHRegistrationNode * pRN, const _s_FuncInfo * pFuncInfo, void * handlerAddress, int CatchDepth, unsigned long NLGCode)  Zeile 442 + 0xc Bytes              C++

                   vcruntime140.dll!CallCatchBlock(EHExceptionRecord * pExcept, EHRegistrationNode * pRN, _CONTEXT * pContext, const _s_FuncInfo * pFuncInfo, void * handlerAddress, int CatchDepth, unsigned long NLGCode)  Zeile 1439 + 0x14 Bytes      C++

                   vcruntime140.dll!CatchIt(EHExceptionRecord * pExcept, EHRegistrationNode * pRN, _CONTEXT * pContext, void * pDC, const _s_FuncInfo * pFuncInfo, const _s_HandlerType * pCatch, const _s_CatchableType * pConv, const _s_TryBlockMapEntry * pEntry, int CatchDepth, EHRegistrationNode * pMarkerRN, unsigned char IsRethrow)  Zeile 1243 + 0x1f Bytes            C++

    >             vcruntime140.dll!FindHandler(EHExceptionRecord * pExcept, EHRegistrationNode * pRN, _CONTEXT * pContext, void * pDC, const _s_FuncInfo * pFuncInfo, unsigned char recursive, int CatchDepth, EHRegistrationNode * pMarkerRN)  Zeile 679 + 0x26 Bytes       C++

                   vcruntime140.dll!__InternalCxxFrameHandler(EHExceptionRecord * pExcept, EHRegistrationNode * pRN, _CONTEXT * pContext, void * pDC, const _s_FuncInfo * pFuncInfo, int CatchDepth, EHRegistrationNode * pMarkerRN, unsigned char recursive)  Zeile 439 + 0x1a Bytes               C++

                   vcruntime140.dll!__CxxFrameHandler3(EHExceptionRecord * pExcept, EHRegistrationNode * pRN, void * pContext, void * pDC)  Zeile 234 + 0x19 Bytes    C++

                   ntdll.dll!ExecuteHandler2@20()  + 0x26 Bytes  

                   ntdll.dll!ExecuteHandler@20()  + 0x24 Bytes     

                   ntdll.dll!_KiUserExceptionDispatcher@8()  + 0xf Bytes  

                   KernelBase.dll!76efdae8()          

                    vcruntime140.dll!_CxxThrowException(void * pExceptionObject, const _s__ThrowInfo * pThrowInfo)  Zeile 131 + 0x13 Bytes             C++

                   Mso40UIwin32client.dll!6fcc5be2()        

                    Mso40UIwin32client.dll!6fb662a5()       

                    Mso40UIwin32client.dll!6fb65910()       

                    Mso40UIwin32client.dll!6fb654aa()       

                    Mso40UIwin32client.dll!6fddfe69()       

                    Mso99Lwin32client.dll!6f5c98e0()          

                    MSO.DLL!64dcd338()    

                    MSO.DLL!64dcd294()    

                    MSO.DLL!64dcd1d4()    

                    ACECORE.DLL!61382071()          

                    ACECORE.DLL!61381fa1()            

                    ACEOLEDB.DLL!6162cf32()         

                    ACEOLEDB.DLL!6162bd2a()        

                    oledb32.dll!CDBInitialize::DoInitialize()  + 0x3b Bytes     

                   oledb32.dll!CDBInitialize::Initialize()  + 0x34 Bytes          

                   oledb32.dll!CSCM::ReleaseFromSessionPool()  + 0x79d3 Bytes  

                   [Übergang von Verwaltet zu Systemeigen]         

    System.Data.dll!System.Data.OleDb.DataSourceWrapper.InitializeAndCreateSession(System.Data.OleDb.OleDbConnectionString constr, ref System.Data.OleDb.SessionWrapper sessionWrapper) Zeile 134 + 0x10 Bytes              C#

    System.Data.dll!System.Data.OleDb.OleDbConnectionInternal.OleDbConnectionInternal(System.Data.OleDb.OleDbConnectionString constr, System.Data.OleDb.OleDbConnection connection) Zeile 115 + 0x10 Bytes             C#

    System.Data.dll!System.Data.OleDb.OleDbConnectionFactory.CreateConnection(System.Data.Common.DbConnectionOptions options, System.Data.Common.DbConnectionPoolKey poolKey, object poolGroupProviderInfo, System.Data.ProviderBase.DbConnectionPool pool, System.Data.Common.DbConnection owningObject) Zeile 39                C#

    System.Data.dll!System.Data.ProviderBase.DbConnectionFactory.CreateConnection(System.Data.Common.DbConnectionOptions options, System.Data.Common.DbConnectionPoolKey poolKey, object poolGroupProviderInfo, System.Data.ProviderBase.DbConnectionPool pool, System.Data.Common.DbConnection owningConnection, System.Data.Common.DbConnectionOptions userOptions) Zeile 573 + 0x14 Bytes           C#

    System.Data.dll!System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(System.Data.Common.DbConnection owningConnection, System.Data.ProviderBase.DbConnectionPoolGroup poolGroup, System.Data.Common.DbConnectionOptions userOptions) Zeile 132 + 0x11 Bytes           C#

    System.Data.dll!System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(System.Data.Common.DbConnection owningConnection, System.Threading.Tasks.TaskCompletionSource<System.Data.ProviderBase.DbConnectionInternal> retry, System.Data.Common.DbConnectionOptions userOptions, System.Data.ProviderBase.DbConnectionInternal oldConnection, out System.Data.ProviderBase.DbConnectionInternal connection) Zeile 292 + 0x28 Bytes             C#

    System.Data.dll!System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(System.Data.Common.DbConnection outerConnection, System.Data.ProviderBase.DbConnectionFactory connectionFactory, System.Threading.Tasks.TaskCompletionSource<System.Data.ProviderBase.DbConnectionInternal> retry, System.Data.Common.DbConnectionOptions userOptions) Zeile 674 + 0x18 Bytes           C#

    System.Data.dll!System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(System.Data.Common.DbConnection outerConnection, System.Data.ProviderBase.DbConnectionFactory connectionFactory, System.Threading.Tasks.TaskCompletionSource<System.Data.ProviderBase.DbConnectionInternal> retry, System.Data.Common.DbConnectionOptions userOptions) Zeile 66 + 0x11 Bytes             C#

    System.Data.dll!System.Data.ProviderBase.DbConnectionInternal.OpenConnection(System.Data.Common.DbConnection outerConnection, System.Data.ProviderBase.DbConnectionFactory connectionFactory) Zeile 650 + 0xf Bytes     C#

                   System.Data.dll!System.Data.OleDb.OleDbConnection.Open() Zeile 529                C#


    Monday, May 30, 2016 1:53 PM

All replies

  • Just an idea, perform a check that the connection is really closed before you go further.

    MS is VERY happy to cache data to increase "performance" (which often have the opposite effect). I have many cases where MS caching does not do what's intended but instead present a huge mismatch between cached data and actual data (example OneDrive, Upload Center and more).


    Best regards, George


    Monday, May 30, 2016 2:31 PM
  • >>>We get an AccessViolation Exception if we try to insert data into several Excel Sheets using .NET and the ACE OLEDB driver (32Bit, Office 2016).<<<

    According to your description, could you provide sample code and screenshot, that will help us reproduce and resolve your issue.

    In addition transfer Data to a Worksheet by Using ADO.NET, you could refer to this link below:

    https://support.microsoft.com/en-us/kb/306023

    Thanks for your understanding.
    Tuesday, May 31, 2016 6:13 AM
  • I have broken down the problem to the following points:

    - Office 2016 has to be installed
    - OleDb Connection Pooling has to be switched on: OLE DB Services=-1 (this is the default) See https://msdn.microsoft.com/en-us/library/windows/desktop/ms724518%28v=vs.85%29.aspx
    - Open a OleDbConnection to Excel workbook or Access database 1
    - Open a OleDbConnection to Excel workbook or Access database 2
    - Wait at least one minute
    - Try to open the connection again
    - The Access Violation occurs at connection1.Open()

    c# Winforms sample:

    void button1_Click(object sender, EventArgs e)
    {
        var connection1=new OleDbConnection(
    "Provider=Microsoft.ACE.OLEDB.12.0;OLE DB Services=-1;Data Source=\"test1.xlsx\";Mode=Share deny none;Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=1;READONLY=TRUE\";");

       connection1.Open();
       connection1.Close();

       var connection2=new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;OLE DB Services=-1;Data Source=\"test2.accdb\";Mode=Read;");
       connection2.Open();
       connection2.Close();
    }



    Thursday, June 2, 2016 3:34 PM
  • Hi Alex Werner,

    This is the forum to discuss questions and feedback for Excel for Developers, I suggest that you could post your question to the MSDN forum for ADO.NET Managed Providers

    https://social.msdn.microsoft.com/Forums/en-US/home?forum=adodotnetdataproviders&filter=alltypes&sort=lastpostdesc

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us.

    Thank you for your understanding.
    • Marked as answer by David_JunFeng Wednesday, June 8, 2016 2:35 PM
    • Unmarked as answer by David_JunFeng Wednesday, June 8, 2016 2:35 PM
    Monday, June 6, 2016 7:33 AM
  • I will try that. Thank you
    Monday, June 6, 2016 12:41 PM
  • Hi Alex Werner,

    Hope your resolving this issue.

    Thanks for your understanding.


    Friday, June 10, 2016 9:53 AM