Matt Frear Matt Frear - 1 year ago 153
C# Question

Unit test with Microsoft.Office.Interop dll fails on build server

I've written a unit test. The code under test references Microsoft.Office.Interop.Excel.dll.

The test runs fine on my machine but fails on the build server. It fails on the line where the Excel application is instantiated:

var application = new Application { Visible = Visible };

The error is:

Retrieving the COM class factory for component with CLSID
{00024500-0000-0000-C000-000000000046} failed due to the following error:
80040154 Class not registered

Does this mean I have to install the Redistributable Primary Interop Assemblies on my build server? And if so, do I also need to install Excel on the build server?

Microsoft.Office.Interop.Excel.dll is included in my solution and it is referenced from there.

Answer Source

You'll need to install Office and the Primary Interop Assemblies for that version, or Visual Studio to get this to work. You might run into COM issues with running in a CI environment, and if you can restructure your tests to avoid using Office Interop, I'd highly recommend it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download