У меня есть простое C # консольное приложение:
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ImporterRidistribuzioni
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("ImporterRidistribuzioni START");
string path = "C:\\WS\\RegoleInoltro\\TunnelPro-DistribuzioneTitolario.xlsx";
ReadREgoleInoltroFrmExcelFile(path);
Console.WriteLine("ImporterRidistribuzioni END");
}
public static void ReadREgoleInoltroFrmExcelFile(string filePath)
{
DataTable regoleInoltro;
string oleDBConnectionString = GetOleDBConnectionString(filePath);
using (OleDbConnection conn = new OleDbConnection(oleDBConnectionString))
{
conn.Open();
OleDbCommand cmd = new OleDbCommand();
cmd.Connection = conn;
// Get all Sheets in Excel File
DataTable dtSheet = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
/// Prendo il nome del primo foglio
DataRow dr = dtSheet.Rows[0];
string sheetName = dr["TABLE_NAME"].ToString();
//regoleInoltro = GetDataTablePerimetro(cmd, sheetName);
cmd = null;
conn.Close();
}
//return regoleInoltro;
}
}
}
Моя проблема в том, что когда он пытается выполнить эту строку:
conn.Open();
я получаю это исключение: "Поставщик« Microsoft.ACE.OLEDB.12.0 »не зарегистрирован на локальном компьютере.
Вот подробности:
- $exception {"The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine."} System.InvalidOperationException
+ Data {System.Collections.ListDictionaryInternal} System.Collections.IDictionary {System.Collections.ListDictionaryInternal}
HResult -2146233079 int
HelpLink null string
+ InnerException null System.Exception
Message "The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine." string
Source "System.Data" string
StackTrace " at System.Data.OleDb.OleDbServicesWrapper.GetDataSource(OleDbConnectionString constr, DataSourceWrapper& datasrcWrapper)\r\n at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)\r\n at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)\r\n at System.Data.ProviderBase.DbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)\r\n at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)\r\n at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)\r\n at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)\r\n at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)\r\n at System.Data.ProviderBase.DbConnectionInternal.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)\r\n at System.Data.OleDb.OleDbConnection.Open()\r\n at ImporterRidistribuzioni.Program.ReadREgoleInoltroFrmExcelFile(String filePath) in C:\\WS\\ArxeiaProtocollo2016\\ImporterRidistribuzioni\\Program.cs:line 32\r\n at ImporterRidistribuzioni.Program.Main(String[] args) in C:\\WS\\ArxeiaProtocollo2016\\ImporterRidistribuzioni\\Program.cs:line 19" string
+ TargetSite {Void GetDataSource(System.Data.OleDb.OleDbConnectionString, System.Data.OleDb.DataSourceWrapper ByRef)} System.Reflection.MethodBase {System.Reflection.RuntimeMethodInfo}
Я работаю над Windows Server 2012 в облаке Azure.
Я установил 64-битную версию этого инструмента: https://www.microsoft.com/en-us/download/details.aspx?id=13255
как указано здесь: Поставщик «Microsoft.ACE.OLEDB.12.0» не зарегистрирован на локальном компьютере.
но ничего не меняется. Я все еще получаю ту же ошибку.
Почему? Что мне не хватает? Как я могу попытаться решить эту проблему?