XP SP3上的HttpListener.IsSupported为false

时间:2012-04-05 09:53:30

标签: c# .net httplistener

我们正在尝试部署一个简单的C#(框架2.0)应用程序,该应用程序在Windows XP SP3系统上使用HttpListener类:应用程序在初始化时中止,因为HttpListener.IsSupported属性为false

问题:({1}}在(合理)最新的XP系统上不支持哪些内容?

可能重要的事情:

  • 用户不是其系统的管理员
  • 计算机上可能存在我不知道的安全策略(我不确定我是否可以在不自行管理的情况下进行检查)

2 个答案:

答案 0 :(得分:2)

好的,在引擎盖HttpListener类中调用

[StructLayout(LayoutKind.Sequential)]
internal struct HTTPAPI_VERSION
{
    internal ushort HttpApiMajorVersion;
    internal ushort HttpApiMinorVersion;
}

[DllImport("httpapi.dll", CallingConvention=CallingConvention.StdCall, SetLastError=true, ExactSpelling=true)]
internal static extern unsafe uint HttpInitialize(HTTPAPI_VERSION version, uint flags, void* pReserved);

在XP上:

version.HttpApiMajorVersion = 2; 
version.HttpApiMinorVersion = 0;
flags = 5;
pReserved = null;

其中描述了here。并设置bool supported = HttpInitialize(...) == 0;

您可以尝试使用PInvoke直接调用它并检查system error code返回

答案 1 :(得分:0)

一种可能性:即使使用SP2及更高版本,XP Embedded似乎也不支持HttpListener / http.sys。

相关问题