57

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.

0

10 Answers 10

60

rebuild the solution and the error will go away.

3
  • 2
    This seems painfully simple... but I've been banging my head against the wall about this for a while. Thanks!
    – tordal
    Commented Jan 19, 2012 at 14:55
  • 14
    I have exactly this problem. Rebuilding does not fix it.
    – Ian Gilham
    Commented Aug 29, 2012 at 16:53
  • The fact that this worked is somehow horrifying. But thanks, all the same! Commented Jul 24, 2014 at 14:18
41

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.

3
  • 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
    Commented Jul 13, 2012 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
    Commented Mar 21, 2014 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
    Commented Mar 3, 2015 at 6:56
37

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"
2
  • 3
    This answer should get more attention Commented Apr 29, 2019 at 10:21
  • 1
    This should be promoted; I have a xaml view inside a PatientStorageManager.UI.View and I had to change from xmlns:dataHelper="clr-namespace:PatientManagerMD.ResourceCentral.DataHelper" to xmlns:dataHelper="clr-namespace:PatientManagerMD.ResourceCentral.DataHelper;assembly=PatientManagerMD.ResourceCentral" and it worked. Commented Dec 21, 2021 at 18:28
21

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.

2
  • DO you have more detail around what the errors were?
    – Yecats
    Commented Nov 2, 2014 at 22:35
  • In my case - there was a failure in the constructor for the WPF control from refactoring. When I stepped through with the debugger it was obvious.
    – Sean Doyle
    Commented Jun 24, 2015 at 15:20
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.

1
  • 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
    Commented Oct 11, 2013 at 5: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.

2
  • 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
    Commented Jan 24, 2012 at 9: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
    Commented Jul 26, 2013 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.

1
  • Samething happened to me, couldn't figure out what happened after I removed and readded the project from source control. This answer worked.
    – gavin
    Commented Dec 11, 2013 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
  • As you said- rebuilding the release version didn't work, but rebuilding the debug version made it happy
    – arolson101
    Commented Jan 3, 2012 at 16:31
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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.