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 :)
I am not getting a System.AccessViolationException using GetOleDbSchemaTable
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.