I'm trying to open access connection from a C# application. The connection is being opened the below method :
ADOX.CatalogClass cat = new ADOX.CatalogClass(); System.IO.File.Delete(_AccessDatabaseName); cat.Create("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + _AccessDatabaseName + "; Jet OLEDB:Engine Type=5"); cat = null; _ErrorMessage = ""; return (true);
Everything works fine until i call these methods using a background worker/thread with office 2016. I get the below error :Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Sometimes even this : No error message available, result code: E_UNEXPECTED(0x8000FFFF). It seams the ldb of the access is still opened, so when i cannot access the mdb file after creating it in order to create/insert into any other table. I installed accessruntime_4288-1001_x64_en-us.exe and AccessDatabaseEngine_X64.exe but same errors. Even when trying to create the mdb using cat.Create the application freezes until i have to force close it.
Any help would be great.
I have been looking for a proper solution for the same issue but without success. My workaround is either not to use any background threads or , if background threads needed, using connection string with ‘OLE DB SERVICES = -1’ to enable pooling so that ldb or laccdb could be reused by other connections without creating new one. However, the pooling will render reopening connection errors if the lock file disappears after timeout (1 minute) in 2016 Access Engine. Thus, a stupid solution is to create another thread to open the connection and close it every minute.
It seems to be a bug in MS Access Engine 2016. I am hoping someone could help me not to use this crazy workaround.
User contributions licensed under CC BY-SA 3.0