Ansi9200
Ansi9200

Reputation: 31

32bit ACE OleDb 16.0 Access Violation

I am trying to use ACE OleDB 16 on an excel file. And get {"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."}

System is Office 2016 and the Program Files (x86)\Common\Microsoft Shared\Office 16\ACEOLEDB.dll

Any input on what is going on would be very appreciated (even being called an idiot :) )

Note: The program throws an error although the code is inside a try-catch block;

Sample code:

string path = @"testfile.xlsx";
string connString = "Provider=Microsoft.ACE.OLEDB.16.0;Data Source="+ path +";Extended Properties='Excel 16.0;HDR=No;IMEX=1;'";
DataTable dt = new DataTable();
  try
    {
      OleDbConnection cnnxls = new OleDbConnection(connString);
      OleDbDataAdapter oda = new OleDbDataAdapter(string.Format("select * from [{0}$]", sheet), cnnxls);

       oda.Fill(dt);
      }
  catch (Exception e)
       {
        // error handling
        }

Error output:

System.AccessViolationException was unhandled HResult=-2147467261
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Source=System.Data
StackTrace: at System.Data.OleDb.DataSourceWrapper.InitializeAndCreateSession(OleDbConnectionString constr, SessionWrapper& sessionWrapper) at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection) at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) at System.Data.ProviderBase.DbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionInternal.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.OleDb.OleDbConnection.Open() at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable) at AceOleDbTest.AceOleDbTest.AceReadTest(String connString, String logPath, String sheet) in C:\Users\anokano\documents\visual studio 2015\Projects\AceOleDbTest\AceOleDbTest\AceOleDbTest.cs:line 87 at randomtests3.Program.Main(String[] args) in C:\Users\anokano\Documents\Visual Studio 2015\Projects\randomtests3\randomtests3\Program.cs:line 336 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException:

Upvotes: 1

Views: 1267

Answers (0)

Related Questions