Bug 16261 - WebHeaderCollection not accepting the correct parameters
Summary: WebHeaderCollection not accepting the correct parameters
Status: RESOLVED INVALID
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: 3.2.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2013-11-15 08:45 UTC by Paul Johnson
Modified: 2013-12-06 12:11 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED INVALID

Description Paul Johnson 2013-11-15 08:45:49 UTC
According to Microsoft[1], I should be able to add to the headers being sent to a web service using the likes of 

List<WebHeaderCollection> collection = new List<WebHeaderCollection>;
collection.Add("foo","bar");

This is currently giving an error that there is no such method of Add taking 2 parameters. This would be correct, except that http://msdn.microsoft.com/en-us/library/system.net.webheadercollection(v=vs.110).aspx says there is an override to Add.

I'm attempting to write a PCL and have not tried this on a PC using VS.

[1] http://msdn.microsoft.com/en-us/library/965xw3x5(v=vs.110).aspx
Comment 1 Marek Safar 2013-12-06 10:45:44 UTC
The error is correct. You are adding an item to System.Collections.Generic.List and not to System.Net.WebHeaderCollection.

You like should be 

var collection = new WebHeaderCollection ();
collection.Add("foo","bar");

instead
Comment 2 Paul Johnson 2013-12-06 10:53:15 UTC
Which when you try gives a compiler error that there isn't an overload for Add that accepts two string parameters...
Comment 3 Marek Safar 2013-12-06 12:11:15 UTC
Works fine for me