C# 使用HttpListener时候异常(此平台不支持此操作:System.PlatformNotSupportedException)

 C# 使用HttpListener时候异常(此平台不支持此操作:System.PlatformNotSupportedException)

代码:

HttpListener listener = new HttpListener();

错误:

System.PlatformNotSupportedException: Operation is not supported on this platform

In System.Net.HttpListener..ctor()

解决办法如下:管理员运行cmd,输入如下

 

解决办法如下:管理员运行cmd,输入如下

打开cmd命令行窗口,执行下述2个语句:

sc config http start=demand

sc start http 

执行完成后,再启动试试,基本可以解决

下载链接:https://download.csdn.net/download/LongtengGensSupreme/89003685

下载上述注册表,之后操作如下:

C# 使用HttpListener时候异常(此平台不支持此操作:System.PlatformNotSupportedException)
代码:HttpListener listener = new HttpListener();
错误:System.PlatformNotSupportedException: Operation is not supported on this platform In System.Net.HttpListener..ctor()
出先上述原因可能是注册表项下没有注册http服务,因此需要创建以下 DWORD 注册表值:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\  没有HTTP服务,
可以cmd输入 sc qc http或者sc qc http 可以查看一下,如果没有http服务就需要手动添加注册表

win+R输入 regedit 定位到 HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\ 手动拖拽下载的 http.reg 

手动拖拽http.reg 注册表Services下即可,之后 重启电脑即可。
下载地址 http.reg:https://download.csdn.net/download/LongtengGensSupreme/89003685

 

posted @ 2024-03-21 11:52  龙骑科技  阅读(67)  评论(0编辑  收藏  举报