'Executing SSIS package programmatically using C#

I writing to execute SSIS package using the application. I have written following code but it gives an error. the error is listed below the code.

        public void RunPackage()
    {
        string pkgLocation;
        Package pkg;
        Application app;
        DTSExecResult pkgResults;

        pkgLocation = @"C:\Users\EMISDb\Desktop\NEOC\EOC data need\NEOC_ETL\NEOC_ETL\obj\Development\99_Dash_WHO.dtsx";
        app = new Application();
        pkg = app.LoadPackage(pkgLocation, null);
        pkgResults = pkg.Execute();

    }

error:

Retrieving the COM class factory for component with CLSID {4F0FC44B-C99C-4 41D-B86A-D60D7E22143D} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)). Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {4F0FC44B-C99C-441D-B86A- D60D7E22143D} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

The error at the following line.

Line 27:             app = new Application();


Solution 1:[1]

I was also experiencing this error and installing SQL Server 2017 x64 Express with Advanced Services resolved the issue.

It installed C:\Program Files\Microsoft SQL Server\140\DTS\Binn\DTS.dll and registered the assembly Microsoft.SqlServer.DTSRuntimeWrap, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91 in HKEY_CLASSES_ROOT\CLSID\{4F0FC44B-C99C-441D-B86A-D60D7E22143D}.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rami A.