2012-04-05 51 views
2

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

问:什么可以让HttpListener不支持的一个(合理的)上的最新XP系统上?

事情会重要:

  • 用户不是管理员将其系统上
  • 有可能是在计算机上的安全政策,我不知道(和它的我不知道我能够检查而不被管理员自己)

回答

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:这是描述here

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

。并设置bool supported = HttpInitialize(...) == 0;

您可以尝试直接调用它使用的PInvoke和检查system error code回到

0

一种可能性:XP嵌入式似乎并不能够支持HttpListener/HTTP.SYS即使SP2及更高版本。

相关问题