I am not getting a System.AccessViolationException using GetOleDbSchemaTable

Pat Hanks 141 Reputation points
2023-01-26T15:08:35.0233333+00:00

I am developing an application that has been working just fine until today. The only variable in my environment is I received the latest Windows 10 & Office 365 patches. This code has been functioning fine until after I rebooted from the patches. The line that is causing the error is

DataTable dataTable = databaseConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });

This is a WinForms applications and the database being used is Access 365. Microsoft Visual Studio Professional 2022 (64-bit) - Current, Version 17.4.4

Windows version

Edition Windows 10 Enterprise

Version 21H2

Installed on ‎7/‎12/‎2021

OS build 19044.2486

Experience Windows Feature Experience Pack 120.2212.4190.0

This is the message from the exception.

Executing program C:\WINDOWS\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll | Fault -2147467261 Attempted to read or write protected memory. This is often an indication that other memory is corrupt. occured at System.Data.Common.UnsafeNativeMethods.IDBSchemaRowset.GetRowset(IntPtr pUnkOuter, Guid& rguidSchema, Int32 cRestrictions, Object[] rgRestrictions, Guid& riid, Int32 cPropertySets, IntPtr rgPropertySets, IRowset& ppRowset)

at System.Data.OleDb.OleDbConnectionInternal.GetSchemaRowset(Guid schema, Object[] restrictions)

at System.Data.OleDb.OleDbConnection.GetOleDbSchemaTable(Guid schema, Object[] restrictions)

at OLEDatabaseUtilities.OLEDatabase.CompareSchemaTable(String tableName, List`1 columns) in C:[excluded]\OLEDatabase.cs:line 2998

I have rebooted several times and still the error persists. Any help is appreciated.



Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,827 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,233 questions
Access Development
Access Development
Access: A family of Microsoft relational database management systems designed for ease of use.Development: The process of researching, productizing, and refining new or existing technologies.
821 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Pat Hanks 141 Reputation points
    2023-01-27T16:19:48.11+00:00

    It turned out to be an issue caused by someone renaming a table primary key. The strange part to me is the type of error. I would have expected one of the data exceptions, not the System.AccessViolationException. Oh well onward :)

    0 comments No comments