Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6755885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:27:23+00:00 2026-05-26T13:27:23+00:00

I am really at a loss here, and have been trying to find a

  • 0

I am really at a loss here, and have been trying to find a solution to this for several hours. I am lost. I get the following exception during an operation that was working the last time I checked.

'{DependencyProperty.UnsetValue}' is not a valid value for property 'Foreground'.

It does not take me to where the error is occuring. It takes me to a page that says “No Source Available”, and nothing else. I have tried locating the error by placing breakpoints in various places, but it seems to fail at different points during each run through. The InnerException is null.

I have seen this question, as well as various articles from Google. I cannot figure out what is going on, and I do not know how to troubleshoot from here. The Visual Studio output doesn’t appear to give any more detailed information, but I will paste it on request. Please, any help is appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:27:23+00:00Added an answer on May 26, 2026 at 1:27 pm

    I’m willing to be you have a missing resource. If you do something like:

    <Window x:Name="window" x:Class="WpfApplication4.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:sys="clr-namespace:System;assembly=mscorlib"
            xmlns:local="clr-namespace:WpfApplication4"
            Title="MainWindow" Height="350" Width="525" >
        <Window.Resources>
        <Style TargetType="Button">
            <Setter Property="Foreground" Value="{StaticResource NoSuchResourceKey}" />
        </Style>
        </Window.Resources>
        <StackPanel>
            <Button Content="Click Me" />
        </StackPanel>
    </Window>
    

    Then you will get such an exception. We can even use a ComponentResourceKey to produce this exception:

    <Style TargetType="Button">
        <Setter Property="Foreground" Value="{StaticResource {ComponentResourceKey TypeInTargetAssembly={x:Type FrameworkElement}, ResourceId=NoSuchResourceKey}}" />
    </Style>
    

    There are few things here that cause the issue. Normally, you would get a compiler error saying a resource doesn’t exist when using StaticResource. Such as in this case:

    <Button Content="Click Me" Foreground="{StaticResource NoSuchResourceKey}" />
    

    If instead, we had done:

    <Button Content="Click Me" Foreground="{StaticResource {ComponentResourceKey TypeInTargetAssembly={x:Type FrameworkElement}, ResourceId=NoSuchResourceKey}}" />
    

    Then you would get a different exception (XamlParseException), saying:

    Provide value on ‘System.Windows.StaticResourceExtension’ threw an exception.’ Line number ‘6’ and line position ’22’.

    With an internal exception of:

    Cannot find resource named ‘TargetType=System.Windows.FrameworkElement ID=NoSuchResourceKey’. Resource names are case sensitive.

    Which all leads us to the real problem (a missing resource). The reason the first two examples don’t give us a useful exception, is that we are not setting the Foreground property. We are setting the Value property on a Setter object. So when the resource is not found, DependencyProperty.UnsetValue is used. Which is perfectly valid for the Setter.Value property.

    Later, when the Style is applied to the Button we get the exception, because that’s when the DependencyProperty.UnsetValue is actually assigned to the Button.Foreground property.

    To fix this issue, I’d search over your entire solution for Property="Foreground" and look for any instances that use a resource that doesn’t exist.

    I should add that you don’t get an exception when using DynamicResource, because in that value passed to the Button.Foreground property is a “special value” (which allows deferred lookup). This “special value” won’t assign the given property unless the resource is found.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is really weird.. I have the following redirect in a file: header('Location: http://google.com');
Really ripping my hair out on this one. I have a JAAS Authentication Provider
Really quick jQuery question... I have this function: $(document).ready(function() { $('a#show1').click(function() { $('.item1').toggle(1000); return
I am really at a loss here. i read the MSDN articles thoroughly but
I'm at a complete loss here. I have a method that goes through a
I don't know why I have a memory leak here and would really appreciate
I really need some guidance here as this issue is pretty confusing and extremely
I'm at a loss here, though I've been getting more and more familiar with
I have an array of strings like this: Some Title##DD-MM-JJJJ##Some Text goes here##img1.jpg##img2.jpg I'd
This is really weird and I fear I have just done something dumb but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.