tag does not exist in XML namespace

Viewed 57682

This error seems to be posted all over the place but each one seems to have its own solution, none of which solved my problem.

I am getting an error for a Resource Dictionary I am making (and later merging) that the tag 'ModelBindings' does not exist in XML namespace 'clr-namespace:Company.Project.Module.Folder;assembly=Company.Project.Module'

The assembly I am referencing is custom and contained within the solution. Not only that but we have looked at the dll put into the bin for the project the Resource Dictionary resides in and after inspection it contains the class I want to reference. So I know that 1. the dll is in the right place to be accessed and is in references. 2. The dll contains the data I want.

Here are some bits of code for the Resource Dictionary

The listing of the namespace

xmlns:modulemodel="clr-namespace:Company.Project.Module.Folder;assembly=Company.Project.Module"

Creating the resource to be referenced

<modulemodel:ModelBindings x:Key="ModuleModelBindings"/>

Like the other people's errors the intellisense says its kosher. ALso the xmlns listing was created with intellisense's autocomplete and retyped manually. Neither worked.

I also tried moving everything to app.xaml and it still gave me the same error.

If I remove the body of the ResourceDictionary file the code compiles fine, but all the bindings are broken.

Lastly, all the resource definitions used to be defined within the xaml files where they were used, that worked fine. Its only after I tried creating them from a different project that it didn't work. I changed this to fix an error and going back to the old method could potentially be problematic.

Edit: Here is the best I can do in terms of showing the resource dictionary I am using

<SharedResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:modulemodel="clr-namespace:Company.Project.Module.Folder;assembly=Company.Project.Module"
                    >
    <modulemodel:ModelBindings x:Key="ModuleModelBindings"/>
    
</SharedResourceDictionary>

if I replace SharedResourceDictionary with ResourceDictionary the same error occurs.

app.xaml and the SharedResourceDictionary above are comparetively in the namespace Company.Project.Main and it has references to both where SharedResourceDictionary is defined as well as the different module projects I put into the code above

8 Answers

Check Warnings in error list, in my case there where messages about unresolved .Net 4.5.1 references, while my project target framework was 4.5

If you have user control in same assembly as WPF form make sure you get rid of assembly part while importing namespace

Wrong Import: xmlns:usercontrol="clr-namespace:CCFARKS.UserControls;assembly=CCFARKS"

Corret: xmlns:usercontrol="clr-namespace:CCFARKS.UserControls"

it's an old question but, the problem comes from the .csproj. Be sure the "page" element is defined before the "compile" element in the "itemgroup" section.

Good :

  <ItemGroup>
...
<Page Include="ScreenComponents\StatusBar.xaml">
  <SubType>Designer</SubType>
  <Generator>MSBuild:Compile</Generator>
</Page>
<Compile Include="ScreenComponents\StatusBar.xaml.cs">
  <DependentUpon>StatusBar.xaml</DependentUpon>
</Compile>
…

Not good :

  <ItemGroup>
...
<Compile Include="ScreenComponents\StatusBar.xaml.cs">
  <DependentUpon>StatusBar.xaml</DependentUpon>
</Compile>
<Page Include="ScreenComponents\StatusBar.xaml">
  <SubType>Designer</SubType>
  <Generator>MSBuild:Compile</Generator>
</Page>
…

regards,

This may happen if you have errors other than this specific error also. More errors may cause the file not to compile properly and resulting in this error.

First try to remove other build 'ERRORS' and 'WARNINGS' also. Then rebuild the solution.

Related