Unanswered Intermittent 'DeferrableContent' Exception Raised

  • Monday, August 20, 2012 9:07 PM
     
      Has Code

    I have Wpf window that I create and show on a separate thread that is displayed during long load operations.  It works 99.9999% of the time.  However, on very rare occassions, we see this odd exception get raised:

    2012-08-17 16:13:33,933 FATAL default 10944 [7540] TSystem.Content.ContentFrameworkException: Unable to create BusyMessageWindow ---> System.Windows.Markup.XamlParseException: Failed to create a 'DeferrableContent' from the text 'System.IO.MemoryStream'. ---> System.InvalidOperationException: DeferrableContent is only allowed on ResourceDictionaries.
       at System.Windows.DeferrableContentConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
       at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateObjectWithTypeConverter(ServiceProviderContext serviceContext, XamlValueConverter`1 ts, Object value)
       at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateFromValue(ServiceProviderContext serviceContext, XamlValueConverter`1 ts, Object value, XamlMember property)
       at MS.Internal.Xaml.Runtime.PartialTrustTolerantRuntime.CreateFromValue(ServiceProviderContext serviceContext, XamlValueConverter`1 ts, Object value, XamlMember property)
       at System.Xaml.XamlObjectWriter.Logic_CreateFromValue(ObjectWriterContext ctx, XamlValueConverter`1 typeConverter, Object value, XamlMember property, String targetName, IAddLineInfo lineInfo)
       --- End of inner exception stack trace ---
       at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
       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.LoadComponent(Object component, Uri resourceLocator)
       at TSystem.Content.BusyMessageWindow.InitializeComponent()
       at TSystem.Content.BusyMessageWindow..ctor()
       --- End of inner exception stack trace ---
       at TSystem.Content.BusyMessageWindow..ctor()
       at TSystem.Content.BusyIndicator.ShowMessageWindow(Object parameter) (:0)

    Any thoughts as to what could cause such a problem?

    An addendum:  Since the exception alludes to deferred content, it must have something to do with this dynamic resource that is referenced by a user control displayed on the BusyMessageWindow?

                 Foreground="{DynamicResource ProgressRadialBrush}">
    
        <UserControl.Resources>
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="pack://application:,,,/TSystem.Content.Presentation.Wpf;component/Themes/Brushes.generic.xaml"/>
                </ResourceDictionary.MergedDictionaries>
            </ResourceDictionary>
        </UserControl.Resources>
    

    Thanks,

    Kelly


    Kelly Hilliard


All Replies

  • Wednesday, August 22, 2012 7:48 AM
    Moderator
     
     

    Hi KellyInSeattle,

    It is really hard to find the root cause of your issue, because I could not repro it on my side, and it works 99.9999% of the time.

    could you narrow down your issue with a sample to repro, it will be helpful for me to find the root cause, thank you.

    best regards,


    Sheldon _Xiao[MSFT]
    MSDN Community Support | Feedback to us
    Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • Thursday, August 23, 2012 7:23 AM
    Moderator
     
     

    Hi KellyInSeattle,

    Additional, I suggest you trace or log the parameter below:

    TSystem.Content.BusyIndicator.ShowMessageWindow(Object parameter)

    When the exception is thrown, check what the last parameter is logged, then check whether this parameter can result in any differences in the xaml of the BusyMessageWindow. It is helpful to figure out a repro sample.

    Best regards,


    Sheldon _Xiao[MSFT]
    MSDN Community Support | Feedback to us
    Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • Tuesday, September 04, 2012 9:09 AM
    Moderator
     
     

    Hi KellyInSeattle,

    How about your issue?

    Best regards,


    Sheldon _Xiao[MSFT]
    MSDN Community Support | Feedback to us
    Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • Tuesday, September 04, 2012 3:47 PM
     
     
    No updates as of yet.  I've added additional logging to track the value of "parameter".  The problem here is that this defect only occurs under longevity testing when the system is under load.

    Kelly Hilliard

  • Wednesday, September 05, 2012 2:58 AM
    Moderator
     
     

    Ok, thank you for your feecback, if you have new findings, you could post it.


    Sheldon _Xiao[MSFT]
    MSDN Community Support | Feedback to us
    Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • Tuesday, September 18, 2012 2:38 PM
     
      Has Code

    I thought I had perhaps addressed this issue by no longer using a dynamic resource (see earlier post fo the XAML snippet).  Unfortunately, though, this is still happening.  This ONLY happens when our QA department simulates a very heavy load.  Here is the stack trace:

    2012-09-15 00:35:20,899 FATAL default ShowMessageWindow parameter: BusyIndicatorParms: Location (Top=99,Left=10,Width=926,Height=762), Message ("") (:0) 
    2012-09-15 00:35:20,899 FATAL default TSystem.Content.ContentFrameworkException: Unable to create BusyMessageWindow ---> System.Windows.Markup.XamlParseException: Failed to create a 'DeferrableContent' from the text 'System.IO.MemoryStream'. ---> System.InvalidOperationException: DeferrableContent is only allowed on ResourceDictionaries.
       at System.Windows.DeferrableContentConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
       at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateObjectWithTypeConverter(ServiceProviderContext serviceContext, XamlValueConverter`1 ts, Object value)
       at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateFromValue(ServiceProviderContext serviceContext, XamlValueConverter`1 ts, Object value, XamlMember property)
       at MS.Internal.Xaml.Runtime.PartialTrustTolerantRuntime.CreateFromValue(ServiceProviderContext serviceContext, XamlValueConverter`1 ts, Object value, XamlMember property)
       at System.Xaml.XamlObjectWriter.Logic_CreateFromValue(ObjectWriterContext ctx, XamlValueConverter`1 typeConverter, Object value, XamlMember property, String targetName, IAddLineInfo lineInfo)
       --- End of inner exception stack trace ---
       at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
       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.LoadComponent(Object component, Uri resourceLocator)
       at TSystem.Content.BusyMessageWindow.InitializeComponent()
       at TSystem.Content.BusyMessageWindow..ctor()
       --- End of inner exception stack trace ---
       at TSystem.Content.BusyMessageWindow..ctor()
       at TSystem.Content.BusyIndicator.ShowMessageWindow(Object parameter) (:0) 
    

    I'm extremely confused by this since I no longer (explictly at least) have any dynamic resources. Anyone out there have ANY ideas?

    Thanks,

    Kelly


    Kelly Hilliard

  • Wednesday, September 19, 2012 9:10 AM
    Moderator
     
     

    Hi Kelly,

    I am trying to involve someone familiar with this topic to further look at this issue.

    Best regards,


    Sheldon _Xiao[MSFT]
    MSDN Community Support | Feedback to us
    Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • Wednesday, September 19, 2012 5:44 PM
     
     
    Thanks!

    Kelly Hilliard

  • Monday, September 24, 2012 1:46 PM
     
     

    Just FYI...I have a sample application that I can send...I've not been able to repro the issue, but perhaps someone could examine the code and see some kind of flaw...

    Thanks,

    Kelly


    Kelly Hilliard

  • Tuesday, September 25, 2012 9:07 PM
    Owner
     
     

    We've done some research and could not find any known issues related to this exception. I was unable to find any previous reports of this, so it's not clear why it would be happening. Given the fact that it only occurs under stress, and the application is creating Windows on numerous threads; I suspect this is probably a race condition occurring down somewhere in WPF's internals. Without a reliable way to reproduce the problem, it would be unlikely we could actually fix this issue, however we may be able to work around it. Since we are coming out of the Window's InitializeComponent, we could probably work around this by protecting the contents of the Window's constructors within a lock{} statement. This will serialize access to the InitializeComponent method so that only one thread could call into it at a time, and hopefully avoid any race conditions which are occurring downstream. For example, assuming we had a custom Window class named TestWindow, we could try code like the following.


        private static Object lockObject = new Object();
            public TestWindow()
            {
                lock (lockObject)
                {
                    InitializeComponent();
                }
            }

    Then only one thread at a time would be able to execute InitializeComponent, and hopefully we would be able to avoid the problem.

    If not, then the only other option would be to open a paid support case with Microsoft Developer Support to further investigate the issue: http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone.


    Trevor Hancock (Microsoft)
    Please remember to "Mark As Answer" the replies that help.

  • Monday, October 01, 2012 4:31 PM
     
      Has Code

    Trevor,

    Thanks for this suggestion.  I've added this and will be handing it over to our longevity team in the next few days.  In the meantime, we saw another Wpf exception that was raised from inside InitializeComponent.  Perhaps this will provide you with some more clues as to the nature of the problem?

    2012-09-30 10:02:22,082 FATAL default ShowMessageWindow parameter: BusyIndicatorParms: Location (Top=479,Left=203,Width=164,Height=79), Message ("") (:0) 
    2012-09-30 10:02:22,122 FATAL default TSystem.Content.ContentFrameworkException: Unable to create BusyMessageWindow ---> System.Windows.Markup.XamlParseException: The invocation of the constructor on type 'TSystem.Content.ProgressIndicator' that matches the specified binding constraints threw an exception. ---> System.ArgumentException: An entry with the same key already exists.
       at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
       at System.Collections.Generic.SortedList`2.Add(TKey key, TValue value)
       at System.IO.Packaging.Package.AddIfNoPrefixCollisionDetected(ValidatedPartUri partUri, PackagePart part)
       at System.IO.Packaging.Package.GetPartHelper(Uri partUri)
       at System.IO.Packaging.Package.GetPart(Uri partUri)
       at System.Windows.Application.GetResourceOrContentPart(Uri uri)
       at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
       at TSystem.Content.ProgressIndicator.InitializeComponent()
       at TSystem.Content.ProgressIndicator..ctor()
       at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
       --- End of inner exception stack trace ---
       at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
       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.LoadComponent(Object component, Uri resourceLocator)
       at TSystem.Content.BusyMessageWindow.InitializeComponent()
       at TSystem.Content.BusyMessageWindow..ctor()
       --- End of inner exception stack trace ---
       at TSystem.Content.BusyMessageWindow..ctor()
       at TSystem.Content.BusyIndicator.ShowMessageWindow(Object parameter) (:0) 
    

    Thanks,

    Kelly


    Kelly Hilliard