3

I'm making a UWP Windows app in C# using WinUI 3.0 and a few days ago I started getting this kind of error:

CS0433  The type 'NavigationView' exists in both 'Microsoft.UI.Xaml, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime' and 'Microsoft.UI, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime'

This is the snippet from the auto generated code that causes the error:

[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.UI.Xaml.Markup.Compiler"," 0.0.0.0")]
        private global::Microsoft.UI.Xaml.Controls.NavigationView settingsNavPane; 

Until now, I solved instances of this issue by deleting /bin and /obj's contents, but the problem seems to persist.

I'm aware this is a compiler error, so I tried adding a reference to the .csproj file:

<References>
  <Reference Include="Microsoft.UI.Xaml.dll"/>
</References>

I don't know if I'm missing something obvious, but this didn't solve the problem either. How do I fix this?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197

2 Answers2

0

Derive from your error, it looks you have not specific XamlControlsResources, please refer this document and add XamlControlsResources in your app.xaml file.

<Application.Resources>
    <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
</Application.Resources>
Nico Zhu
  • 32,367
  • 2
  • 15
  • 36
0

The problem is that Microsoft.EntityFrameworkCore.SqlServer after version 7 and greater produceS this problem. Downgrading the version to 6.014 fixed the issue for me.

JD coder
  • 33
  • 1
  • 6