简体   繁体   English

Windows Service上的SignalR自托管

[英]SignalR self hosting on Windows Service

I'm wrote a small POC application (console application) on C# (vs2013) that makes: host and clients. 我在C#(vs2013)上编写了一个小型POC应用程序(控制台应用程序),该应用程序包括:主机和客户端。

The code of the host side: 主机端代码:

string url = "http://*:8900/";

using (WebApp.Start(url))
{
    Console.WriteLine("Server running at " + url);
    lock (just4lock)
        Monitor.Wait(just4lock);
}

It's working only if I'm run my (console) application with "Run as administrator". 仅当我使用“以管理员身份运行”运行我的(控制台)应用程序时,它才有效。

Ok, now I'm want to move this code to my Windows Service application. 好的,现在我想将此代码移到Windows Service应用程序中。 When i'm running the same host code on windows service, I'm getting this error: 当我在Windows服务上运行相同的主机代码时,出现此错误:

An unhandled exception of type 'System.MissingMemberException' occurred in Microsoft.Owin.Hosting.dll

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

My service run as "Local System account". 我的服务以“本地系统帐户”运行。 I'm not see any option to make it's "run as administrator". 我看不到任何使它“以管理员身份运行”的选项。

Do you know a way to make SignalR self-hosting works without administrator? 您是否知道一种无需管理员即可使SignalR自托管工作的方法?

How I'm can make this windows service run as administrator? 如何使该Windows服务以管理员身份运行?

Thanks! 谢谢!

我遇到了同样的问题,对我来说,解决方案是将对程序集Microsoft.Owin.Host.HttpListener的引用添加到我的项目中。

Have you tried with a registered Startup object instead? 您是否尝试过使用注册的Startup对象?

WebApp.Start<Startup>(url);

then... 然后...

class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            app.MapSignalR();
        }
    }

This works just fine for us... 这对我们来说很好

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM