"System.MissingMemberException:找不到服务器工厂"在TeamCity中自行托管Microsoft.Owin [英] "System.MissingMemberException: The server factory could not be located" starting Microsoft.Owin self-hosted in TeamCity

查看:717
本文介绍了"System.MissingMemberException:找不到服务器工厂"在TeamCity中自行托管Microsoft.Owin的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

When Teamcity runs an integration test that starts a self-hosted webapplication, the test fails with the error:

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可执行文件运行测试.

The test runs fine when executed withing Visual Studio (using the Resharper test runner). Teamcity is configured to use the JetBrains.BuildServer.NUnitLauncher.exe executable to run the test.

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

I see a lot of posts regarding this error are to do with the because the Microsoft.Owin.Host.HttpListener.dll is not present in the bin\debug or bin\release folder. I can confirm that this file (and the accompanying .xml file) are both present in the bin\release folder used by the TeamCity buildAgent. There is no bin\debug folder present.

推荐答案

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

I encountered this in my Powershell script that iterates all of our solutions and builds them with MSBuild and then invokes MSTest on all Test projects. This script is used to build & test all solutions locally before committing to TFS. This issue does not arise while running the tests within VS. I believe this to be related to this question.

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

Place the following just before calling WebApp.Start("http://*:52203/") in the test initialization.

// 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) { }

这篇关于"System.MissingMemberException:找不到服务器工厂"在TeamCity中自行托管Microsoft.Owin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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