Unit test with Microsoft.Office.Interop dll fails on build server(在构建服务器上使用 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 };
错误是:
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
这是否意味着我必须在我的构建服务器上安装可再发行主互操作程序集?如果是这样,我是否还需要在构建服务器上安装 Excel?
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 包含在我的解决方案中,并从那里引用.
Microsoft.Office.Interop.Excel.dll is included in my solution and it is referenced from there.
推荐答案
您需要为该版本安装 Office 和主互操作程序集,或 Visual Studio 才能使其正常工作.在 CI 环境中运行时您可能会遇到 COM 问题,如果您可以重组测试以避免使用 Office Interop,我强烈推荐它.
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 进行单元测试失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在构建服务器上使用 Microsoft.Office.Interop dll 进行单元测试失败
基础教程推荐
- 如何激活MC67中的红灯 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30