54

I'm trying to include in my XAML some classes which convert values. However, I'm getting the following error when I compile:

Undefined CLR namespace. The 'clr-namespace' URI refers to a namespace 'View.Summary.Converters' that is not included in the assembly.(View\View)

And the XAML it's erroring on:

xmlns:c="clr-namespace:View.Summary.Converters"

Also, here is the outline of my conversion classes/namespace:

namespace View.Summary.Converters
{
    class CollapsedIfNegative : IValueConverter { }

    class VisibleIfNegative : IValueConverter { }

    class ErrorCodeToString : IValueConverter { }
}

I had to remove the guts of the code because the project I am working on is highly confidential.

abatishchev
  • 92,232
  • 78
  • 284
  • 421
Adam S
  • 8,245
  • 17
  • 60
  • 95

10 Answers10

57

rebuild the solution and the error will go away.

Avinash
  • 595
  • 1
  • 4
  • 3
38

I just solved this by changing the target from x64 to x86. Apparently Visual Studio is 32bit process and it's unable to load 64bit assemblies, and if your assembly is targeting x64 platform and you adding some custom control visual studio is unable to load it and throws this message.

Evgeny
  • 381
  • 1
  • 3
  • 2
  • 1
    Brilliant! :D Always funny to find things like this, but yes, rebuilding as a 32 bit dll did restore the designer for me. Thanks a lot. – Sam Jul 13 '12 at 15:00
  • 1
    AAAAGGgghhhhh... So, instead of URI not in the assembly, they can't say... hey, this is a 64-bit assembly and we can't load through our 32-bit user development interface... that would be TOOOOO easy huh. So, when I want to LOOK at the designer of anything in my 64-bit final project, I need to change to 32-bit and all is good, then swap back to 64 for final deployment. – DRapp Mar 21 '14 at 14:52
  • I feel like this should be a solved problem by now since 32bit is going the way of the dodo for desktop/server where ARM hasn't really taken hold and 32bit apps on 64bit Windows have the whole sysWOW64 train wreck to deal with. All the same, thank you, that solved other problems with the designer too. – sean_m Mar 03 '15 at 06:56
20

If you reference to an external project, you must specify the assembly as it appears in your project's references:

xmlns:mdls="clr-namespace:MyProject.Models;assembly=MyProject.Models"
Jerther
  • 4,801
  • 6
  • 33
  • 53
18

I figured out what was wrong. Although visual studio showed this as the first error, there were indeed other errors with my coding which prevented the converters from being assembled. Thus, when VS went to find the assembly, it was not there.

Adam S
  • 8,245
  • 17
  • 60
  • 95
13

some problem with vs2008 designer

do this:

  1. close the designer
  2. rebuild-all (Alt+B+R) the solution

now there wont be any errors.

joy
  • 131
  • 1
  • 2
  • 1
    This works, when build target changes back,should be an issue with the dll type,for 64 bit application start the build with 64 bit, incase if you build first x86 and then change to x64, leads you to this issue. – Jay Oct 11 '13 at 05:47
8

I was able to reproduce your issue:

I created a simple WF in .NET Framework 4.0. Renamed the xaml file. As part of renaming the xaml file you have to manually rename the workflow runtime name when calling the Invoke on the WorkflowInvoker object. I build the project. I got the error "The 'clr-namespace' URI refers to a namespace 'System' that is not included in the assembly."

How I fixed it:

I open the project property page. For some reason, the target framework was switch from .NET framework 4.0 to 4.0 client version. So, I selected .NET 4.0 and rebuilt the project. The error is not there anymore.

H A
  • 1,244
  • 2
  • 23
  • 39
  • Just had this problem too and this solved it: my assembly was set to Client Profile but was referencing assemblies that were Full Profile... – Josh Jan 24 '12 at 09:37
  • This was my problem also. The main WPF application was set to .Net 4.0 Client Profile, my control library was .Net 4.0. Switching the WPF app to .Net 4.0 solved the problem. – James Hay Jul 26 '13 at 10:19
3

Check that your build configuration has the Project selected for build in your current (Active) build configuration.

I just had this problem after fiddling with the Build architecture (from x86 to x64) and the main wpf project had been de-selected.

Ash
  • 4,741
  • 6
  • 32
  • 48
  • Samething happened to me, couldn't figure out what happened after I removed and readded the project from source control. This answer worked. – gavin Dec 11 '13 at 19:57
2

I have ran into this issue on a C# WPF project. It seems to be generated when you closed the project with last attempt with Errors of any kind during your project not even in the relevant Namespace in issue in XAML.

The solution to this is to fix all .CS files (Or exclude the problematic XAML/CS files) to get a running version Rebuild and run.

It took me close to 3 hours to figure that the Debug version that the designer seems to be running on must be faulty. This is why in many cases people resolved this with Rebuild project, but in cases that you have existing code errors in project the issue will not resolve it self since the Rebuild fails to complete and does not replace the designer supported version.

hoped this helps!

1

Visual Studio keeps reverting back to the odd assembly file paths. Just delete the actual reference file it's referring to and then add it to the project

0

I had the same error. But apparently, it was just because of the path of the solution that I was trying to build. My path/directory/folder name contains some spaces.

fleur
  • 115
  • 11