System.Web.MimeMapping static constructor crash due to incorrect string comparer use - by geraint_e

Status : 

  Duplicate<br /><br />
		This item appears to be a duplicate of another existing Connect or internal item.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


3
0
Sign in
to vote
ID 661862 Comments
Status Closed Workarounds
Type Bug Repros 2
Opened 4/15/2011 2:05:41 AM
Access Restriction Public

Description

the static constructor of System.Web.MimeMapping crashes when adding standard MIME types to a Hashtable.

Looking at the reflected code in that class, it's adding MIME types to a hashtable using a culture-specific string comparer:

static MimeMapping()
{
    _extensionToMimeMappingTable = new Hashtable(190, StringComparer.CurrentCultureIgnoreCase);
    AddMimeMapping(".323", "text/h323");
    AddMimeMapping(".asx", "video/x-ms-asf");
etc...

The bug is that the MimeMapping static constructor should be using an _InvariantCulture_ string comparer when adding these types into the HashTable.

In culture cy-gb, G and F are considered to be equal (this is another bug, but never mind!). So when it comes to adding in the .GIF type, it complains that the item already exists - because .FIF is already in the hashtable. This is some code which may help clarify the comparisons:

StringComparer.CurrentCultureIgnoreCase.Equals(".g", ".f")
true
StringComparer.CurrentCultureIgnoreCase.Equals(".gif", ".fif")
true
StringComparer.CurrentCultureIgnoreCase.Equals(".gif", ".fig")
true
StringComparer.CurrentCultureIgnoreCase.Equals(".g", ".h")
false 


Sign in to post a comment.
Posted by Scott [MSFT] on 4/18/2011 at 10:46 PM
This was a duplicate of another issue.
Posted by Macy [MSFT] on 4/18/2011 at 2:41 AM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by eddieyanez on 4/15/2011 at 2:26 AM
This looks the same as https://connect.microsoft.com/VisualStudio/feedback/details/565556/stringcomparer-for-culture-cy-gb-gives-wrong-answers
Posted by Microsoft on 4/15/2011 at 2:13 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)