gpt4 book ai didi

.net - "System.MissingMemberException: The server factory could not be located"启动 Microsoft.Owin 在 TeamCity 中自托管

转载 作者:行者123 更新时间:2023-12-03 23:17:22 30 4
gpt4 key购买 nike

当 Teamcity 运行启动自托管 Web 应用程序的集成测试时,测试失败并显示错误:

System.MissingMemberException: The server factory could not be located for the given input: Microsoft.Owin.Host.HttpListener

抛出此错误的代码是:
var webApp = WebApp.Start<Startup>("http://*:52203/")

使用 Visual Studio(使用 Resharper 测试运行程序)执行时,测试运行良好。 Teamcity 配置为使用 JetBrains.BuildServer.NUnitLauncher.exe可执行以运行测试。

我看到很多关于这个错误的帖子都是因为 Microsoft.Owin.Host.HttpListener.dll不存在于 bin\debug 或 bin\release 文件夹中。我可以确认此文件(以及随附的 .xml 文件)都存在于 TeamCity buildAgent 使用的 bin\release 文件夹中。不存在 bin\debug 文件夹。

最佳答案

我在我的 Powershell 脚本中遇到了这个问题,该脚本迭代我们所有的解决方案并使用 MSBuild 构建它们,然后在所有测试项目上调用 MSTest。此脚本用于在提交到 TFS 之前在本地构建和测试所有解决方案。在 VS 中运行测试时不会出现此问题。我相信这与this question有关.

在测试初始化​​中调用 WebApp.Start("http://*:52203/") 之前放置以下内容。

// This uber silly code is needed to ensure the Owin HttpListener assembly 
// is properly copied to the output directory by using it, utterly redonkulous.
var uberSillyNecessity = typeof(OwinHttpListener);
if (uberSillyNecessity != null) { }

关于.net - "System.MissingMemberException: The server factory could not be located"启动 Microsoft.Owin 在 TeamCity 中自托管,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30050588/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com