【发布时间】:2016-12-24 09:33:17
【问题描述】:
我的 Program.cs 中有以下代码,用于在 Mono 4.2.2 上启动一个自托管的 nancy 应用程序。
public static void Main (string[] args)
{
var uri = "";
if(ReflectConfiguration.CurrentEnviroment == ReflectConfiguration.Environments.Production || ReflectConfiguration.CurrentEnviroment == ReflectConfiguration.Environments.Staging)
{
uri = string.Format("http://localhost:{0}", Environment.GetEnvironmentVariable("PORT").ToString());
}
else if(ReflectConfiguration.CurrentEnviroment == ReflectConfiguration.Environments.Development)
{
uri = string.Format("http://localhost:8888");
}
Console.WriteLine("Starting Reflect.Web application on " + uri);
// initialize an instance of NancyHost
var host = new NancyHost(new Uri(uri));
host.Start(); // start hosting
// check if we're running on mono
if (Type.GetType("Mono.Runtime") != null)
{
// on mono, processes will usually run as daemons - this allows you to listen
// for termination signals (ctrl+c, shutdown, etc) and finalize correctly
UnixSignal.WaitAny(new[] {
new UnixSignal(Signum.SIGINT),
new UnixSignal(Signum.SIGTERM),
new UnixSignal(Signum.SIGQUIT),
new UnixSignal(Signum.SIGHUP)
});
}
else
{
Console.ReadLine();
}
host.Stop(); // stop hosting
}
这段代码运行了好几个月。刚刚开始出现这个错误:
System.Net.Sockets.SocketException: Could not resolve host '+'
在这一行:
host.Start(); // start hosting
我不知道我最近对任何依赖项进行了任何更新。
以前有人遇到过这种情况吗?为什么是“+”号?
【问题讨论】: