Question

We are trying to deploy a simple C# (framework 2.0) application which uses HttpListener class on a Windows XP SP3 system: the application aborts at initialization because HttpListener.IsSupported property is false.

Question: what could make HttpListener unsupported on a (reasonably) up-to-date XP system ?

Things that could matter:

  • User is not administrator on his system
  • There may be security policies on the computer which I'm not aware of (and which I'm not sure I am able to check without being administrator myself)
Was it helpful?

Solution

Okay, under the hood HttpListener class calls

[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);

On XP:

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

Which is described here. And sets bool supported = HttpInitialize(...) == 0;

You can try to call it directly using PInvoke and check system error code returned

OTHER TIPS

One possibility: XP Embedded does not seem to be supporting HttpListener/http.sys even with SP2 and later.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top