title: WPF on Windows 7: GetCultureInfo in ValueConverter causing StaticResourceExtension exception on Provide Value
body: <p>I'm sorry if the title is a bit confused, but I don't really know how to shortly describe this issue. 
  I have a wpf windows application that runs fine in Windows 8 and 10 but crashes on Windows 7 when loading the main interface. 
  The exception the application was retunring was this:</p>
  
  <blockquote>
    <p>Provide value on 'System.Windows.StaticResourceExtension' threw an
    exception. StackTrace :   at
    System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader,
    IXamlObjectWriterFactory writerFactory, Boolean
    skipJournaledProperties, Object rootObject, XamlObjectWriterSettings
    settings, Uri baseUri)    at
    System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader,
    Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel
    accessLevel, Uri baseUri)    at
    System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext
    parserContext, Object parent, Boolean closeStream)    at
    System.Windows.Application.LoadBamlStreamWithSyncInfo(Stream stream,
    ParserContext pc)    at System.Windows.Application.LoadComponent(Uri
    resourceLocator, Boolean bSkipJournaledProperties)    at
    System.Windows.Application.DoStartup()    at
    System.Windows.Application.&lt;.ctor>b__1(Object unused)    at
    System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate
    callback, Object args, Int32 numArgs)    at
    MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object
    source, Delegate method, Object args, Int32 numArgs, Delegate
    catchHandler)</p>
  </blockquote>
  
  <p>Google told me that the issue may be the order in which I defined some static resources (<a href="https://stackoverflow.com/questions/13861866/provide-value-on-system-windows-staticresourceextension">Provide value on &#39;System.Windows.StaticResourceExtension</a>) in my xaml file. Actually I have some DataTemplate defined as static resources in the Window.Resources tag, but as that post said, they are defined in the right order and the Window.Resources tag is the first child of the Window tag:</p>
  
  <pre><code>&lt;Window x:Class="FlyMasterSyncGui.Forms.FlightLog"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:local="clr-namespace:FlyMasterSyncGui.Forms"
      xmlns:formsUtils="clr-namespace:FlyMasterSyncGui.FormsUtils"
      Title="FlymasterSync" Height="372" Width="608"
      Icon="../Assets/icon.ico"
      WindowStartupLocation="CenterScreen"
      Closed="FlightLog_OnClosed"
      Closing="FlightLog_OnClosing" Loaded="FlightLog_OnLoaded"&gt;
  
  &lt;Window.Resources&gt;
  
      &lt;CollectionViewSource x:Key="groupedFlights" Source="{Binding TracksDb.Entries}"&gt;
          &lt;CollectionViewSource.GroupDescriptions&gt;
              &lt;PropertyGroupDescription PropertyName="FlightInfo.Date" Converter="{formsUtils:YearConverter}" /&gt;
              &lt;PropertyGroupDescription PropertyName="FlightInfo.Date" Converter="{formsUtils:MonthConverter}" /&gt;
          &lt;/CollectionViewSource.GroupDescriptions&gt;
      &lt;/CollectionViewSource&gt;
  
      &lt;DataTemplate x:Key="InnerTemplate"&gt;
          &lt;Grid Margin="0,10,0,0"&gt;
              &lt;Border VerticalAlignment="Bottom" Background="#FF9CA7B4" 
  Padding="5,0,0,0"&gt; 
  [...]
  </code></pre>
  
  <p>Though, in this xaml I'm using some ValueConverters and after some attempts I found out that it is the MonthConverter that is firing the exception. The converter code is the following: </p>
  
  <pre><code>public class MonthConverter : MarkupExtension, IValueConverter
  {
      private MonthConverter _converter;
  
      public MonthConverter()
      {
      }
  
      public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
      {
          DateTime d = (DateTime)value;
  
          //Exception Here
          var monthName = CultureInfo.GetCultureInfo("en-en").DateTimeFormat.GetMonthName(d.Month);                         
          return char.ToUpper(monthName[0]) + monthName.Substring(1);
      }
  
      public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
      {
          throw new NotSupportedException();
      }
  
      public override object ProvideValue(IServiceProvider serviceProvider)
      {
          if (_converter == null) _converter = new MonthConverter();
          return _converter;
      }
  }
  </code></pre>
  
  <p>The exception is called when I call: </p>
  
  <pre><code>CultureInfo.GetCultureInfo("en-en").DateTimeFormat.GetMonthName(d.Month);
  </code></pre>
  
  <p>And I don't really understand why. 
  At the moment I just made a custom function that converts the month number into its name, so I don't need to call CultureInfo and I fixed the problem, but I'd like to know why this exception is fired and why it only happens on Windows 7.
  Is xaml parsed differently in Windows 7?
  Is the CultureInfo data loaded later on Window 7?</p>
  
  <p>Thanks in advance for any reply :)</p>