Strange error in WPF projects after upgrading to Visual Studio 2022.
Some weeks ago, I updated from Visual Studio 2019 to 2022. Since then, I am getting a strange error in the Xaml editor.
Error XDG0047 The specified value cannot be assigned. The following type was expected: "Object".
This results in the preview of the view not working and just showing „Invalid Markup“.
So far I was not able to find out what seems to be the problem. I suspect a bug in the Xaml editor, as the project compiles and runs perfectly.
I have the same problem.
Was this reported for Microsoft?
Not from me. 🙂
Hi, we have the same problem did you find a solution?
I think its a bug in Visual Studio and we have to wait for a fix.
Same issue here VS 2022 v17.0.4
It appeared first when I enabled Intellisense
Same problem after enabling „IntelliSense“ at studio.
Version is 17.1.1.
I don’t know, how to fully disable IntelliSense for xaml 🙁
And in project I use lib GalaSoft.MvvmLight.
When I open VS 2019, all works perfect.
I think the solution, for now, is to have the preview and not to lose the IntelliSense, so make a design DataContext on Xaml, and in the behind code, set the DataContext to the ViewModel. You won’t get the error, and the design preview works.
XAML:
xmlns:viewModel=“clr-namespace:CustomProject.ViewModels“
d:DataContext=“{d:DesignInstance Type=viewModel:ViewModel, IsDesignTimeCreatable=False}“
BehindCode
using CustomProject.ViewModels;
// in the Constructor
public CustomView()
{
InitializeComponent();
DataContext = new ViewModel();
}
I hope this comment will be helpful because I suffered from this error!