Determines whether the runtime preserves legacy behavior in formatting operations with System.TimeSpan values.
Attributes and Elements
The following sections describe attributes, child elements, and parent elements.
Specifies whether the runtime uses legacy formatting behavior with System.TimeSpan values.
The runtime does not restore legacy formatting behavior.
The runtime restores legacy formatting behavior.
The root element in every configuration file used by the common language runtime and .NET Framework applications.
Contains information about runtime initialization options.
Starting with the .NET Framework 4, the System.TimeSpan structure implements the IFormattable interface and supports formatting operations with standard and custom format strings. If a parsing method encounters an unsupported format specifier or format string, it throws a FormatException.
In previous versions of the .NET Framework, the TimeSpan structure did not implement IFormattable and did not support format strings. However, many developers mistakenly assumed that TimeSpan did support a set of format strings and used them in composite formatting operations with methods such as String.Format. Ordinarily, if a type implements IFormattable and supports format strings, calls to formatting methods with unsupported format strings usually throw a FormatException. However, because TimeSpan did not implement IFormattable, the runtime ignored the format string and instead called the TimeSpan.ToString() method. This means that, although the format strings had no effect on the formatting operation, their presence did not result in a FormatException.
For cases in which legacy code passes a composite formatting method and an invalid format string, and that code cannot be recompiled, you can use the <TimeSpan_LegacyFormatMode> element to restore the legacy TimeSpan behavior. When you set the enabled attribute of this element to true, the composite formatting method results in a call to TimeSpan.ToString() rather than TimeSpan.ToString(String, IFormatProvider), and a FormatException is not thrown.