Question

I have a project created using Visual Studio 2008 targeting .NET 3.5 which makes use of the HttpListenerRequest class. As part of a statistics collection mechanism, all properties of the class are written to a file.

I recently attempted to convert the project from a VS2008 solution to a VS2010 solution and had no errors at all during the conversion, but as soon as I attempt to build the project the compiler claims that it can't find "HttpListenerRequest.ServiceName" and "HttpListenerRequest.TransportContext".

On both of these project the target framework is .NET Framework 3.5, I have compared the DLL version numbers being referenced and everything seems identical.

I decided to examine the HttpListenerRequest classes metadata in both version of visual studio to discover that while 2010 has no reference to ServiceName and TransportContext as expected, VS2008 shows both properties, but neither have the summary description.

Then I created a project targeting .NET 4 in VS2010 which allows me to reference both the above properties.

I really need to continue to target .NET 3.5, do you know of anyway I can make this work without changing the code to exclude so much functionality?

EDIT: As requested, this is the code:

void Log(System.Net.HttpListenerContext context)
{
    string line =
            DateTime.Now.ToString() + "|" +
            context.Request.HttpMethod + "|" +
            context.Request.RawUrl + "|" +
            context.Request.Url.ToString() + "|" +
            context.Request.RemoteEndPoint.ToString() + "|" +
            (context.Request.UrlReferrer == null ? "None" : context.Request.UrlReferrer.ToString()) + "|" +
            (context.Request.ServiceName == null ? "None" : context.Request.ServiceName) + "|" + // Error Here on ServiceName
            context.Request.UserHostName + "|" +
            context.Request.UserAgent + "|" +
            context.Request.TransportContext.ToString() + "|" + // Error here on TransportContext
            context.Request.ProtocolVersion + "|" +
            context.Request.ContentLength64.ToString();

    WriteToFile(line);
}
Was it helpful?

Solution

So I figured it out:

Both versions of Visual Studio only supplied me with the following version info for System.dll: v2.0.50727

But after going to the windows directory and examining the files, there is a version difference. The one which does not include the properties is version v2.0.50727.3053, while version v2.0.50727.3634 includes them.

I assume the problem is that I have had Windows updates disabled since installing Windows.

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