我正在使用Windows窗體應用程序將數據導出爲excel。OleDbConnection獲取「外部組件已引發異常。」
應用程序構建於x64和x86之上。
因此,兩個版本的Microsoft Access Databse Engine必須安裝在同一臺計算機上運行應用程序。
首先安裝AccessDatabaseEngine.exe 並將AccessDatabaseEngine_x64.exe安裝爲被動模式。
應用的x 64版本的工作
但x86版越來越
SEHException: "External component has thrown an exception."
at System.Data.Common.UnsafeNativeMethods.IDBInitializeInitialize.Invoke(IntPtr pThis)
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, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.OleDb.OleDbConnection.Open()
的代碼部分低於;
var accessConnection = new OleDbConnection(connectionString);
accessConnection.Open();
而且ConnectionString的是
Provider=Microsoft.ACE.OLEDB.12.0;Data Source="C:\Users\Me\Desktop\ExportTest.xls";Extended Properties="Excel 8.0;HDR=Yes";
我該如何解決呢?
我現在一直在努力解決這個問題。同樣的情況:由於我們的應用需要同時支持,因此安裝了Access Engine Engine 2010 x86和x64。它首先出現在我們的C++應用程序的OLEDB支持中,但也在.NET中得到證實。我敢打賭,.NET沒有看到你的SEH異常代碼是「Module not found」。 這似乎是64分之32位訪問引擎之間的一些問題,但在這裏示出了REGEDIT正確的路徑: (64位) HKEY_CLASSES_ROOT \ CLSID \ {3BE786A0-0366-4F5C-9434-25CF162E475E} \ InprocServer32的 (32-bit) HKEY_CLASSES_ROOT \ Wow6432Node \ CLSID \ {3BE786A0-0366-4F5C-9434-25CF162E475E} \ InprocServer32 – Jonas
進一步的調查顯示了它在x86驅動程序安裝時的工作方式。當安裝x64時,它將打破x86版本。但這很奇怪,因爲它應該工作。許多指南顯示如何並行安裝這些,即使它沒有得到Microsoft的正式支持。 – Jonas