1

Tenho um método para compactar minha base Access, porém quando rodo o programa tenho o seguinte erro:

Erro:

A exception do catch trás esta mensagem: {"Retrieving the COM class factory for component with CLSID {DE88C160-FF2C-11D1-BB6F-00C04FAE22DA} failed due to the following error: 80040154 Classe não registrada (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))."} System.Exception {System.Runtime.InteropServices.COMException}

Não consegui identificar. Segue código:

try
{
    JRO.JetEngine jetEngine = (JRO.JetEngine)Activator                        
                     .CreateInstance(Type.GetTypeFromProgID("JRO.JetEngine"));
    var arquivoTemporario = System.IO.Path.GetTempFileName();
    arquivoTemporario = System.IO.Path.ChangeExtension(arquivoTemporario, "mdb");
    string templateConnectionString = "Data Source={0};Provider=Microsoft.Jet.OLEDB.12.0;";
    string connectionStringFonte = string.Format(templateConnectionString, caminhoMdb);
    string connectionStringTemp=string.Format(templateConnectionString,arquivoTemporario);

    jetEngine.CompactDatabase(connectionStringFonte,connectionStringTemp);
    System.IO.File.Copy(arquivoTemporario, caminhoMdb, true);
    System.IO.File.Delete(arquivoTemporario);
}
catch (Exception ex)
{
    MessageBox.Show(ex.Message);
}
2
  • A exception do catch trás esta mensagem: {"Retrieving the COM class factory for component with CLSID {DE88C160-FF2C-11D1-BB6F-00C04FAE22DA} failed due to the following error: 80040154 Classe não registrada (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))."} System.Exception {System.Runtime.InteropServices.COMException}
    – user93952
    27/11/2017 às 12:56
  • coloca isso na sua pergunta, por favor, ajuda na visualização do problema. não esqueça de colocar entre "" (igual eu coloquei o seu JRO error" 27/11/2017 às 12:57

1 Resposta 1

0

No Visual Studio vá em propriedades do projeto, na tab de Build selecione a opção platform target =X86.

Fonte: Retrieving the COM class factory for component with CLSID {XXXX} failed due to the following error: 80040154

1
  • Obg Leonado, problema resolvido!
    – user93952
    27/11/2017 às 16:16

Você deve fazer log-in para responder a esta pergunta.