Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MC3074 - type does not exist in "clr-namespace..."

Im having trouble referencing classes in xaml from other assemblies.

In the same solution, i have two projects. One called Controls (to hold user controls) and one called DataBinding (holding converters / validation rules). In a control, im attempting reference a validation rule in xaml:

<Binding.ValidationRules>
   <databind:Validators.FileExistsRule />
</Binding.ValidationRules>

My project references the project containing my classes. Ive added this declaration at the top of my Control.xaml:

xmlns:databind="clr-namespace:GuiParts.DataBinding;assembly=DataBinding"

However, when i compile, i get an error:

The tag 'Validators.FileExistsRule' does not exist in XML namespace 'clr-namespace:GuiParts.DataBinding;assembly=DataBinding'.

The class definitely exists, i can call it in the code behind with no problems, but not via xaml. If i move the class to the same project, again, i have no problems. Ive seen other questions on here, and have tried the following:

  1. Cleaning and rebuilding all relevant projects
  2. Ensuring all projects are targeting the same version of .Net (4.0, Full Profile)
  3. Removing the 'assembly' definition from the end of the namespace definition.

None of the above has worked. Any suggestions as to where im going wrong?

EDIT

My FileExists Validator:

namespace GuiParts.DataBinding.Validators
{
   /// <summary>
   /// Validates that the file with the specified name exists
   /// </summary>
   public class FileExistsRule : ValidationRule
   {
      public override ValidationResult Validate(object value, CultureInfo cultureInfo)
      {
         ValidationResult res = null;
         res = ( ! File.Exists((string)value))
                  ? new ValidationResult(false, "File does not exist")
                  : new ValidationResult(true, null);
         return res;
      }
   }
}

I can call the following in the code behind without any errors:

new GuiParts.DataBinding.Validators.FileExistsRule();

So ive got my namespaces etc. correct.

like image 431
richzilla Avatar asked Jul 17 '12 18:07

richzilla


1 Answers

Try this:

xmlns:databind="clr-namespace:GuiParts.DataBinding.Validators;assembly=DataBinding"

<Binding.ValidationRules>    
    <databind:FileExistsRule />    
</Binding.ValidationRules> 
like image 90
Peter Hansen Avatar answered Nov 16 '22 03:11

Peter Hansen