“System.MissingMemberException: The server factory could not be located” starting Microsoft.Owin self-hosted in TeamCity

怎甘沉沦 提交于 2019-12-04 00:10:37
Adam Caviness

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.

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

I was having same issue: Runs fine locally, but fails on TeamCity agent.

My test project had a reference, through nuget, to Microsoft.Owin.Host.HttpListener

What worked for me was explicitly loading the Microsoft.Owin.Host.HttpListener dll before starting the web app.

// load assembly
AppDomain.CurrentDomain.Load(typeof(Microsoft.Owin.Host.HttpListener.OwinHttpListener).Assembly.GetName());
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!