... all I'm offering is the truth. Nothing more. RSS 2.0
# Thursday, March 12, 2009

I was investigating and en error recently with DateTime.ToString() that gave produced the following call stack:

System.FormatException: Input string was not in a correct format.

at System.DateTimeFormat.GetRealFormat(String format, DateTimeFormatInfo dtfi)

at System.DateTimeFormat.ExpandPredefinedFormat(String format, DateTime& dateTime, DateTimeFormatInfo& dtfi)

at System.DateTimeFormat.Format(DateTime dateTime, String format, DateTimeFormatInfo dtfi)

at System.DateTime.ToString(String format, IFormatProvider provider)

at MyWork.NewMethod(string a, string b)

I was doing the following…

DateTime.ToString(“o”)

…which is a valid input string for 2.0 and above but not 1.1. This would not have been issue but the test PC I ran the offending assembly on had both 1.1 and 2.0. The ToString() method took the path of least resistance and used the framework dependencies under 2.0 and not 1.1. Of course the real problem arises when you try to rerun the assembly on a machine that only has .NET 1.1, at this point the “o” option is invalid.

 

Took me a few moments to track down, and reminded me never to trust MSDN (defaults to .NET 3.x) without verifying the backward compatibility of the options.

 

 

Thursday, March 12, 2009 5:16:00 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] - Trackback
.NET | C#
Blogroll
Statistics
Total Posts: 330
This Year: 18
This Month: 2
This Week: 0
Comments: 30
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2010
Mark Downie
Sign In
All Content © 2010, Mark Downie
DasBlog theme 'Business' created by Christoph De Baene (delarou)