Errors after upgrading project to vs2022
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:
to:
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:
The error is a bit cryptic:
However, I have found that if I import the app resources xaml file at the top of the user control, the errors go away:
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
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:
Code: Select all
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
Code: Select all
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>Here's an example of code that worked find in vs2019 but is giving us an error in vs2022:
Code: Select all
<TextBlock Text="{Binding Foo}" Style="{StaticResource Text.Caption}" />
Code: Select all
XDG0010 'StaticResourceExtension' is not valid for Setter.Value. The only supported MarkupExtension types are DynamicResourceExtension and BindingBase or derived types.
Code: Select all
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Assets/Scripts/Runtime/Client/UI/AppResources.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
thanks,
sam
Re: Errors after upgrading project to vs2022
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:
The I rebuilt the proejct and opened MainWindow.xaml and assigned the Text.Caption style:
And this is the error I'm receiving:
Is Blend vs2022 just not support for noesis at this point?
thanks,
sam
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:
Code: Select all
<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>
Code: Select all
<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"/>
Code: Select all
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
thanks,
sam
Re: Errors after upgrading project to vs2022
Adding an image here that shows the error I mentioned above.
thanks,
sam
thanks,
sam
-
-
sfernandez
Site Admin
- Posts: 3363
- Joined:
Re: Errors after upgrading project to vs2022
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:
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.
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:
Code: Select all
<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>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.I have found that if I import the app resources xaml file at the top of the user control, the errors go away
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