Ale*_*der 10 c# .net-core asp.net-core visual-studio-2017 asp.net-core-2.0
我将应用程序从.NET 4移植到.NET Core,无法找到HttpListener类的模拟
Error CS0246 The type or namespace name 'HttpListener' could not be found (are you missing a using directive or an assembly reference?)
Run Code Online (Sandbox Code Playgroud)
UPDATE1
private readonly HttpListener _httpListener;
if (!HttpListener.IsSupported)
{
throw new NotSupportedException(
"The Http Server cannot run on this operating system.");
}
_httpListener = new HttpListener();
_httpListener.Prefixes.Add(prefix);
_sessionSettings = settings;
Run Code Online (Sandbox Code Playgroud)
Mar*_*ich 17
正如评论中所提到的,WebListener(在Microsoft.Net.Http.ServerNuGet包中)是最接近的替代品,但具有不同的API.或者,还有Kestrel HTTP服务器,它最好从ASP.NET Core堆栈中使用,但可以单独使用(但很难设置).
如果您正在移植,我建议等到.NET Core 2.0,它具有HttpListener跨平台工作的API兼容性,并且不需要您完全更改代码.
在.NET Core 2.0中我们没有这个问题(感谢Martin Ullrich),所以现在我们需要安装Visual Studio Preview 2017版本15.3,我们可以使用.NET Core 2.0.
但默认情况下(目前为最低)没有.NET Core 2.0,我们需要在VS 2017安装后安装它.
PS: - 再次感谢Martin Ullrich - 这太棒了,仅仅是5月10日(我提出要求的前3天).NET Core 2.0 正在宣布 - 我现在拥有它
| 归档时间: |
|
| 查看次数: |
4298 次 |
| 最近记录: |