We are deploying a full-framework (.Net 4.5.1) website to an IIS server.
We are intermittently experiencing the error:
Application Error: System.AggregateException: One or more errors occurred. ---> System.Exception: SelectAllTOCBasedOnRole failed to execute. ---> System.InvalidOperationException: The .Net Framework Data Providers require Microsoft Data Access Components(MDAC). Please install Microsoft Data Access Components(MDAC) version 2.6 or later. ---> System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {2206CDB2-19C1-11D1-89E0-00C04FD7A829} failed due to the following error: 800703fa Illegal operation attempted on a registry key that has been marked for deletion. (Exception from HRESULT: 0x800703FA).
The site is accessing a DB2 database.
MDAC 2.8.1 is installed on the server. Microsoft OLE DB Provider for DB2 Version 5.0 is also installed on all machines running the site.
If we restart the application pool the error is resolved for a while. The error will then, randomly, start again and continue until the app pool is restarted again.
The same web app is on another server that doesn't seem to exhibit this issue though I cannot see any actual differences between the servers and what components they have installed.
The piece of code that is connecting to the DB2 instance is below. Maybe there is something funky in this..?
public async Task<IList<WebTOC>> GetAllTOCAsync(string countryCode, string languageCode, string employeeNumber, string tocIdentifier)
{
IList<WebTOC> results = new List<WebTOC>();
using (OleDbConnection connection = new OleDbConnection(_connectionString))
{
// Parameter order matters with OLEDBCommands
try
{
using (OleDbCommand command = connection.CreateCommand())
using (OleDbDataAdapter adapter = new OleDbDataAdapter(command))
{
command.CommandText = _selectAllTOCCommand;
command.Parameters.AddWithValue("?", $"{tocIdentifier}%");
command.Parameters.AddWithValue("?", countryCode);
command.Parameters.AddWithValue("?", languageCode);
command.Parameters.AddWithValue("?", employeeNumber);
command.Parameters.AddWithValue("?", DateTime.Now.ToString("yyyy-MM-dd"));
LogHelper.Log($"Prepare DB2 Command selectAllToCCommand", level: LogHelper.LogLevel.Debug);
//// FAILS HERE WHEN ATTEMPING TO OPEN THE CONNECTION ////
connection.Open();
try
{
using (INullSafeDataReader dataReader = new NullSafeDataReader(await command.ExecuteReaderAsync()))
try
{
results = dataReader.MapToList<WebTOC>(true);
}
finally
{
dataReader.Close();
}
}
catch (Exception exDR)
{
LogHelper.Log($"Failed to read data from DB2", level: LogHelper.LogLevel.Error);
throw new Exception("Failed to read data from database.", exDR);
}
}
}
catch (Exception ex)
{
/// HITS THIS CATCH ///
LogHelper.Log($"SelectAllTOCBasedOnRole failed to execute", level: LogHelper.LogLevel.Error);
throw new Exception("SelectAllTOCBasedOnRole failed to execute.", ex);
}
finally
{
if (connection.State != System.Data.ConnectionState.Closed)
connection.Close();
connection.Dispose();
}
}
return results;
}
User contributions licensed under CC BY-SA 3.0