C# 使用HttpListener时候异常(此平台不支持此操作:System.PlatformNotSupportedException)
代码:
HttpListener listener = new HttpListener();
错误:
System.PlatformNotSupportedException: Operation is not supported on this platform
In System.Net.HttpListener..ctor()
解决办法如下:管理员运行cmd,输入如下
>sc qc http [SC] GetServiceConfig SUCCESS SERVICE_NAME: http TYPE : 1 KERNEL_DRIVER START_TYPE : 3 DEMAND_START ERROR_CONTROL : 1 NORMAL BINARY_PATH_NAME : System32\Drivers\HTTP.sys LOAD_ORDER_GROUP : TAG : 0 DISPLAY_NAME : HTTP DEPENDENCIES : SERVICE_START_NAME : >sc query http SERVICE_NAME: http TYPE : 1 KERNEL_DRIVER STATE : 1 STOPPED (NOT_STOPPABLE,NOT_PAUSABLE,IGNORES_SHUTDOWN) WIN32_EXIT_CODE : 0 (0x0) SERVICE_EXIT_CODE : 0 (0x0) CHECKPOINT : 0x0 WAIT_HINT : 0x0
解决办法如下:管理员运行cmd,输入如下
打开cmd命令行窗口,执行下述2个语句:
sc config http start=demand
sc start http
执行完成后,再启动试试,基本可以解决
标签:http,NAME,SERVICE,C#,System,PlatformNotSupportedException,HttpListener From: https://www.cnblogs.com/1175429393wljblog/p/17525213.html