Search

ContentDisposition Date FormatException when set/get Date by Des

Closed
as Fixed Help for as Fixed

1
0
Sign in
to vote
Type: Bug
ID: 516979
Opened: 12/1/2009 7:16:33 AM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
When I set a valid DateTime on one of the date properties of the ContentDisposition object, I get an error when I try retrieve the date. It seems the error occurs if the hour, minute, or second component of the DateTime is 0. I tracked down the issue to the MailBnfHelper.ReadDateNumber method using Reflector, it throws a FormatException if the number it reads is 0.
Details (expand)

Product Language

English

Version

.NET Framework 2.0 SP1

Operating System

Windows 7

Operating System Language

English

Steps to Reproduce

Here is some code that will reproduce the issue:

using System;
using System.Net.Mime;

class Program
{
static void Main(string[] args)
{
var disposition = new ContentDisposition();

TrySetGetCreationDate(disposition, new DateTime(2009, 12, 1, 0, 1, 1));
TrySetGetCreationDate(disposition, new DateTime(2009, 12, 1, 1, 0, 1));
TrySetGetCreationDate(disposition, new DateTime(2009, 12, 1, 1, 1, 0));

Console.WriteLine("Press [Enter] to exit");
Console.ReadLine();
}
private static void TrySetGetCreationDate(ContentDisposition disposition, DateTime date)
{
try
{
disposition.CreationDate = date;
Console.WriteLine("Creation Date: " + disposition.CreationDate);
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
}

Actual Results

System.FormatException: The date is in an invalid format.
at System.Net.Mime.MailBnfHelper.ReadDateNumber(String data, Int32& offset, Int32 maxSize)
at System.Net.Mime.MailBnfHelper.ReadDateTime(String data, Int32& offset)
at System.Net.Mime.ContentDisposition.get_CreationDate()
at Program.TrySetGetCreationDate(ContentDisposition disposition, DateTime date) in C:\Users\XXX\Documents\Visual Studio 2008\Projects\DateTester\DateTester\Program.cs:line 22
System.FormatException: The date is in an invalid format.
at System.Net.Mime.MailBnfHelper.ReadDateNumber(String data, Int32& offset, Int32 maxSize)
at System.Net.Mime.MailBnfHelper.ReadDateTime(String data, Int32& offset)
at System.Net.Mime.ContentDisposition.get_CreationDate()
at Program.TrySetGetCreationDate(ContentDisposition disposition, DateTime date) in C:\Users\XXX\Documents\Visual Studio 2008\Projects\DateTester\DateTester\Program.cs:line 22
System.FormatException: The date is in an invalid format.
at System.Net.Mime.MailBnfHelper.ReadDateNumber(String data, Int32& offset, Int32 maxSize)
at System.Net.Mime.MailBnfHelper.ReadDateTime(String data, Int32& offset)
at System.Net.Mime.ContentDisposition.get_CreationDate()
at Program.TrySetGetCreationDate(ContentDisposition disposition, DateTime date) in C:\Users\XX\Documents\Visual Studio 2008\Projects\DateTester\DateTester\Program.cs:line 22
Press [Enter] to exit

Expected Results

Creation Date: 1/12/2009 12:01:01 AM
Creation Date: 1/12/2009 1:00:01 AM
Creation Date: 1/12/2009 1:01:00 AM
Press [Enter] to exit
      You can indicate your satisfaction with how Microsoft handled this issue by completing this quick 3 question survey.

 

File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 12/4/2009 at 8:56 AM
This issue has been fixed in the .NET 4.0 Framework.

Thank you,

Network Class Library Team
Posted by Microsoft on 12/3/2009 at 8:54 PM
Thanks for your feedback.

We are routing 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 Microsoft on 12/2/2009 at 2:55 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)
Sign in to post a workaround.