OpenCurrentDatabase generates System.AccessViolationException

0

I have a C# WPF app that needs to automate the creation of an Access 2016 database.

It executes the following code:

try
            {
                var tempDb = new Access.Application();
                tempDb.OpenCurrentDatabase(tempDbPathFile);

On the line for OpenCurrentDatabase the following exception is raised:

System.AccessViolationException occurred HResult=0x80004003
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source=Microsoft.Office.Interop.Access StackTrace: at Microsoft.Office.Interop.Access.ApplicationClass.OpenCurrentDatabase(String filepath, Boolean Exclusive, String bstrPassword) at AccessLauncher.WPF.Launcher.ExportFormsAndQueries(String tempDbPathFile, String userDbPathFile)

I'm not using interop for Access97 - just for Access2016. The only interaction the app has to make with 97 is to copy an existing empty 97 database to a local folder then populate it by selecting into from Sql Server via an OleDbCommand.

I have tried the same code on several PCs and I only get the error on PCs that have both Access2016 and Access97 installed. Unfortunately, this is a requirment since the application must be able to create different databases in both formats - which users subsequent open (in either Access97 or Access2016 as appropriate) to edit.

Any ideas how this could be resolved?

c#
wpf
ms-access
com-interop
office-automation
asked on Stack Overflow Apr 30, 2018 by Rob Bowman • edited Apr 30, 2018 by Rob Bowman

1 Answer

1

Access_2013 dropped support for the Access_97 file format. Some people have reported that Access_2016 is even more insistent on having absolutely nothing to do with Access_97 files.

This question discusses the issue in more detail. TL;DR: A business application that requires support for both Access_2016 and Access_97 is

  • obviously not an officially supported configuration, and
  • likely to be a source of ongoing headaches if it can be made to work at all.

My advice: Bite the bullet and migrate away from the Access_97 file format.

answered on Stack Overflow Apr 30, 2018 by Gord Thompson

User contributions licensed under CC BY-SA 3.0