samc
Topic Author
Posts: 94
Joined: 21 Aug 2019, 19:22

Errors after upgrading project to vs2022

03 Oct 2023, 06:43

Hi,

I was trying to upgrade our blend project from visual studio 2019 to visual studio 2022. We had to make a single change to the project to get it to load:

we changed:
    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
to:
    <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
Now that it loads, we can build, and there are no errors. However, if we open any xaml that is using a style pulled in from app.xaml, it appears that it cannot be found.

Here's an example of code that worked find in vs2019 but is giving us an error in vs2022:
                <TextBlock Text="{Binding Foo}" Style="{StaticResource Text.Caption}" />
The error is a bit cryptic:
XDG0010	'StaticResourceExtension' is not valid for Setter.Value. The only supported MarkupExtension types are DynamicResourceExtension and BindingBase or derived types.
However, I have found that if I import the app resources xaml file at the top of the user control, the errors go away:
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Assets/Scripts/Runtime/Client/UI/AppResources.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
Is there any way to fix this? Or has anyone else encountered this? I suppose I could add the resource dictionary to the top of all my user controls -- it just seems bad that I'd have to do that. It seems like without it, though, blend is missing all the items defined in that resource dictionary.

thanks,
sam
 
samc
Topic Author
Posts: 94
Joined: 21 Aug 2019, 19:22

Re: Errors after upgrading project to vs2022

04 Oct 2023, 20:07

I decided to try this using the ApplicationTutorial code from this repo: https://github.com/Noesis/Tutorials

I had to upgrade to 4.8 to be able to open in Blend vs2022, and then I added a style to the App.xaml and then I get this error (very similar to what I'm seeing in my own project).

I changed the App.xaml to include a "Text.Caption" style:
<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:noesis="clr-namespace:NoesisGUIExtensions;assembly=Noesis.GUI.Extensions"
             StartupUri="MainWindow.xaml"
             x:Class="RssReader.App">

  <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/Noesis.GUI.Extensions;component/Theme/NoesisTheme.DarkBlue.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <SolidColorBrush x:Key="Background0" Color="#FF2F3F4F" />
            <SolidColorBrush x:Key="Background1" Color="SlateGray" />
            <SolidColorBrush x:Key="Foreground0" Color="White" />
            <SolidColorBrush x:Key="Foreground1" Color="SkyBlue" />
            <SolidColorBrush x:Key="Foreground2" Color="Black" />
            <SolidColorBrush x:Key="Border0" Color="LightSlateGray" />
            <Style x:Key="Text.Caption" TargetType="TextBlock">
                <Setter Property="FontFamily" Value="{StaticResource Font.Family.Whitney}"/>
                <Setter Property="FontSize" Value="14"/>
                <Setter Property="FontWeight" Value="Regular"/>
                <Setter Property="Foreground" Value="{StaticResource Brush.Light.Light}"/>
                <Setter Property="noesis:Text.CharacterSpacing" Value="25"/>
            </Style>
        </ResourceDictionary>
  </Application.Resources>

</Application>
The I rebuilt the proejct and opened MainWindow.xaml and assigned the Text.Caption style:
          <TextBlock x:Name="EntryTitle" Text="Article Title"
                     Style="{StaticResource Text.Caption}"
                     Grid.Row="0" FontSize="20" FontWeight="Bold"
                     Foreground="{StaticResource Foreground1}" TextAlignment="Center"
                     Margin="0,5,0,5"/>
And this is the error I'm receiving:
Severity	Code	Description	Project	File	Line	Suppression State
Error	XDG0018	'StaticResourceExtension' is not valid for Setter.Value. The only supported MarkupExtension types are DynamicResourceExtension and BindingBase or derived types.	ApplicationTutorial-blend	D:\projects\Noesis-Tutorials\Samples\ApplicationTutorial\C#\Src\App.xaml	18	
Is Blend vs2022 just not support for noesis at this point?

thanks,
sam
 
samc
Topic Author
Posts: 94
Joined: 21 Aug 2019, 19:22

Re: Errors after upgrading project to vs2022

04 Oct 2023, 20:08

Adding an image here that shows the error I mentioned above.
image (48).png
thanks,
sam
 
User avatar
sfernandez
Site Admin
Posts: 3363
Joined: 22 Dec 2011, 19:20

Re: Errors after upgrading project to vs2022

05 Oct 2023, 09:55

Hi Sam,

I was able to reproduce it in the ApplicationTutorial following your steps and the error message is super confusing because the source of the problem is that the Style is defining some setters with StaticResources that don't exist (the FontFamily and Foreground setters in this case). With the following style definition there are no errors:
<Style x:Key="Text.Caption" TargetType="TextBlock">
  <Setter Property="FontSize" Value="14"/>
  <Setter Property="FontWeight" Value="Regular"/>
  <Setter Property="Foreground" Value="{StaticResource Foreground2}"/>
  <Setter Property="noesis:Text.CharacterSpacing" Value="25"/>
</Style>
I have found that if I import the app resources xaml file at the top of the user control, the errors go away
This is not recommended at all because you will be loading the same resources over and over again and it will increase the memory and break the performance.

It seems Blend 2022 is more aggresive on finding those kind of broken resource references. You should be able to fix them and keep the shared resources in the ApplicationResources dictionary as expected. Please let me know if you find any trouble with that.

Who is online

Users browsing this forum: Bing [Bot] and 5 guests