与Microsoft.Office.Interop DLL单元测试构建服务器上失败 [英] Unit test with Microsoft.Office.Interop dll fails on build server

查看:96
本文介绍了与Microsoft.Office.Interop DLL单元测试构建服务器上失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个单元测试。被测代码引用Microsoft.Office.Interop.Excel.dll。

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

在测试运行我的机器上正常,但未能在生成服务器上。它失败在哪里Excel应用程序实例化的行:

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:

System.Runtime.InteropServices.COMException: 
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?

修改上安装Excel:
Microsoft.Office.Interop。 Excel.dll包括在我的解决方案,它是从那里引用。

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

推荐答案

您需要安装Office和主Interop程序该版本或Visual Studio来得到这个工作。你可能会在一个CI环境中运行碰上COM的问题,如果你能调整你的测试,以避免使用Office互操作,我强烈推荐它。

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.

这篇关于与Microsoft.Office.Interop DLL单元测试构建服务器上失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆