Using VS2012 working on a VB.NET WPF application. I have a simple MusicPlayer tutorial app I am using to learn WPF. I am converting a C# version of the tutorial to VB.NET step by step.
It has 2 classes in the app that are both under the same namespace. I am able to reference the namespace in the XAML but when I try to reference the class object in XAML I get an error and I am not able to compile.
Strange thing is that the IntelliSense works fine with both referencing the namespace via the xmlns:c= tag and also when typing the class object using <c:
But the object is underlined and errors are generated trying to build or work in the designer.
The .vb class files are in a folder called Controls. The Main project Root Namespace is intentionaly left blank. The class is coded like this…
Namespace MusicPlayer.Controls
Public Class UpdatingMediaElement
.... code here
End Public
End Namespace
The xaml looks like this
(namespace defined in the <Window > tag
xmlns:c="clr-namespace:MusicPlayer.Controls"
(object defined in a <Grid> )
<c:UpdatingMediaElement Name="MyMediaElement" />
(error displayed)
The name «UpdatingMediaElement» does not exist in the namespace «clr-namespace:MusicPlayer.Controls».
Not sure what is wrong or how to fix it?
asked Feb 2, 2013 at 19:40
4
When you are writing your wpf code and VS tell that «The name ABCDE does not exist in the namespace clr-namespace:ABC». But you can totally build your project successfully, there is only a small inconvenience because you can not see the UI designing (or just want to clean the code).
Try to do these:
-
In VS, right click on your Solution -> Properties -> Configuration Properties
-
A new dialog is opened, try to change the project configurations from Debug to Release or vice versa.
After that, re-build your solution. It can solve your problem.
answered Aug 1, 2014 at 11:07
Toan NCToan NC
2,8501 gold badge13 silver badges6 bronze badges
26
If the assembly is different from the namespace in which your class is contained, you have to specfiy it explicitly.
ex:-
xmlns:Local="clr-namespace:MusicPlayer.Controls;assembly=MusicPlayer"
slavoo
5,64864 gold badges36 silver badges39 bronze badges
answered Apr 1, 2013 at 11:35
5
In my case it was because of other compile errors. When other errors have been solved this seemingly related error was also removed from the list. Specially the errors at the bottom of the errors list and on pages you have recently changed.
So do not pay attention to this error directly and focus on other errors at first.
Bugs
4,4919 gold badges32 silver badges41 bronze badges
answered May 28, 2013 at 9:48
ImanIman
17.4k6 gold badges79 silver badges89 bronze badges
5
I’ve seen this issue go away by clearing the Xaml Design Shadow Cache. I had the issue with Visual Studio 2015 Update 1.
In Visual Studio 2015 the Cache is located here:
%localappdata%MicrosoftVisualStudio14.0DesignerShadowCache
Process:
- Right-Click on the solution in the Solution Explorer and Choose «Clean Solution»
- Shutdown Visual Studio
- Delete the ShadowCache folder
- Reopened the Visual Studio project
- Rebuild the solution
And voila no more namespace errors.
answered Mar 3, 2016 at 18:44
1iveowl1iveowl
1,5621 gold badge19 silver badges30 bronze badges
6
Try changing the build target platform to x86 and building the project.
I noticed via Subversion that I apparently changed the project build Platform target to x64. This was the only change I had made. After making that change, the code was working for a short while before it started showing the same error you experienced. I changed the platform target to x86 to test and suddenly my designer was working again. Subsequently, I changed it back to x64, and the problem has disappeared completely. I suspect that the designer builds some kind of cached code in x32 and changing the x64 build platform breaks it when you make code changes.
answered Dec 26, 2014 at 22:00
teynonteynon
7,19110 gold badges61 silver badges101 bronze badges
7
Maybe another solution for when the project compiles but the XAML error is showing :
- In solution explore, on the project node that contains the xaml
- Right-click on the project and choose ‘Unload Project’
- Right-click on the project and choose ‘Reload Project’
Make sure that your project is still choosen as «startup project». If not : - Right-click on the project and choose ‘Set as startup project’
No need to rebuild, or close visual studio.
answered Mar 24, 2017 at 14:33
SimonSimon
2,1671 gold badge21 silver badges24 bronze badges
0
Jesus… This is still a problem five years later in Visual Studio 2017. Since I’m new to WPF, I was sure the problem was somehow me, but no, everything compiled and ran correctly.
I tried rebuilding, cleaning and rebuilding, switching between x86/x64 output, rebooting Windows, cleaning the ShadowCache folder, adding «;assembly={my main assembly name}» to the XML namespace declaration, nothing worked! The single thing that did:
Put my static class of Commands (in my case the deal was about making the design discover my WPF Commands) in its separate assembly and changing the assembly name to that one’s instead.
answered Dec 15, 2017 at 9:36
JonasJonas
1,1321 gold badge16 silver badges25 bronze badges
Dunno if this will help anyone else
I’m new to WPF and still a novice with VB.net — so I was assuming that getting this error was being caused by me doing summit silly…….. suppose I was really! I’ve managed to get rid of it by moving my project from a shared drive to one of my local drives.
Error’s disappeared, project compiles perfectly no further issues — yet. Looks like VS2015 still has problems with projects held on a shared drive.
answered Mar 14, 2016 at 18:12
Supa StixSupa Stix
1442 silver badges4 bronze badges
2
I had this problem recently using VS 2015 Update 3 for my WPF project in .NET 4.6.2. The copy of my project was in a network folder, I moved it locally and that solved the problem.
This may solve other sort of problems, as it looks like VS 2015 doesn’t like network paths. Another issue that is a big problem for them is syncing git repositories if my project is in a network path, also solved by moving it locally.
answered Sep 28, 2016 at 10:37
gbdavidgbdavid
1,61917 silver badges38 bronze badges
I went through all the answers and none helped me. Finally was able to solve it by myself, so presenting the answer as it might help others.
In my case, the solution had two projects, one containing the models (say the project and assembly name was Models) and another containing the views and view models (as per our convention: project, assembly name and default namespace were Models.Monitor). The Models.Monitor referred Models project.
In the Models.Monitor project, in one of the xaml I included the following namespace:
xmlns:monitor=»clr-namespace:Models.Monitor»
I suspect that MsBuild and Visual Studio then were erroring out as they were trying to find a ‘Monitor’ type in the assembly ‘Models’. To resolve I tried the following:
- xmlns:monitor=»clr-namespace:Models.Monitor;assembly=» — which is valid if the namespace is in same assembly as per https://msdn.microsoft.com/en-us/library/ms747086(v=vs.110).aspx
- also tried the explicit namespace declaration:
xmlns:monitor=»clr-namespace:Models.Monitor;assembly=Models.Monitor»
Neither of the above worked.
Finally I gave up, and as a work around moved the UserControl I was trying to use to another namespace: ‘ModelsMonitor’. I was able to compile fine after that.
answered Jun 2, 2017 at 19:07
0
I’m also having a lot of trouble with this one! Intellisense helps me complete the namespace and everything, but the compiler cries. I’ve tried everything I found in this and other threads. However in my case what helped in the end was writing something like this:
xmlns:util="clr-namespace:LiveSpielTool.Utils;assembly="
Leaving the assembly name empty. No idea why. But it was mentioned here. I must add I am developing an assembly, so the assembly attribute might make sense. But entering the assembly name did not work. So weird.
StayOnTarget
11k10 gold badges49 silver badges75 bronze badges
answered Nov 26, 2018 at 12:10
I had the same problem , and in my case the the Markup Design View asked me to rebuild the solution and did not show me the form layout with this message:
Design view is unavailable for x64 and ARM target platforms, or Build the Project to update Design view.
It does not get solved by rebuilding the solution (neither the design view nor the «The name does not exist in the namespace» error)
I think it was because I had played with the settings on Solution -> Properties > Configuration Properties
I finally resolved the problem with 2 jobs:
- Checking all check boxes on Build Column of the page: Solution -> Properties -> Configuration Properties
- Changing the solution configurations from Debug to Release or vice versa.
I think it’s a bug in Visual Studio2012 Update 2.
amhed
3,6392 gold badges30 silver badges56 bronze badges
answered Jun 2, 2013 at 13:55
Ehsan AbidiEhsan Abidi
8918 silver badges24 bronze badges
The same problem plagues Visual Studios 2013, Service Pack 4.
I also tried it with Visual Studios 2015 Preview with the same results.
It’s just a limitation of the WPF visualizer which the Visual Studios team hasn’t fixed.
As proof, building in x86 mode enables the visualizer and building in x64 mode disables it.
Strangely enough intellisense works for Visual Studios 2013, Service Pack 4.
answered Jan 15, 2015 at 23:24
In my case the problem was due to some phantom files under the project’s obj directory. The following fixed the issue for me:
- Clean project
- Exit VS
- rm -rf /obj/*
- Invoke VS and rebuild
answered Apr 30, 2019 at 20:30
In my case, it was just a weird bug.
I had the class I was trying to use in my namespace however Visual Studio kept throwing an error saying the class did not exist in the given namespace.
What I did to fix it was really silly but worked like a charm.
I commented out all the lines of code where I was trying to use the class, cleaned the build, rebuilt and the project was up and running.
Then I just uncommented the lines of code I had commented earlier and well, Visual Studio was no longer throwing me any errors.
Rebuild again and you are ready to go.
answered Jun 5, 2022 at 3:45
Looks like this problem may be solved through a variety of «tricks.»
In my case, I had been building/rebuilding/cleaning the entire solution, instead of just the project that I was working on within the solution. Once I clicked «Build [my project],» the error message went away.
answered Jul 25, 2016 at 23:40
Try verifying your assembly references. If you have a yellow exclamation mark on the project references there’s a problem there and you’ll get all kinds of errors.
If you know the project reference is correct, check the Target framework. For instance, having a project using the 4.5 framework reference a project with 4.5.2 framework is not a good combination.
answered Jul 22, 2016 at 7:44
1
The solution for me was to unblock the assembly DLLs. The error messages you get don’t indicate this, but the XAML designer refuses to load what it calls «sandboxed» assemblies. You can see this in the output window when you build. DLLs are blocked if they are downloaded from the internet. To unblock your 3rd-party assembly DLLs:
- Right click on the DLL file in Windows Explorer and select Properties.
- At the bottom of the General tab click the «Unblock» button or checkbox.
Note: Only unblock DLLs if you are sure they are safe.
answered Feb 21, 2017 at 15:15
JordanJordan
9,5229 gold badges71 silver badges138 bronze badges
1
In my case, the user control was added to the main project. I tried various solutions above to no avail. Either I would get Invalid Markup but the solution would compile and work, or I would add the
xmlns:c=»clr-namespace:MyProject;assembly=MyProject» and then the markup would show, but I would get a compile error that the tag does not exist in the XML namespace.
Finally, I added a new WPF User Control Library project to the solution and moved my user control from the main project into that one. Added the reference and changed the assembly to point to the new library and finally the markup worked and the project compiled without error.
answered Apr 3, 2017 at 15:59
Kevin CookKevin Cook
1,9021 gold badge17 silver badges16 bronze badges
In my case I had a namespace and class spelled exactly the same, so for example, one of my namespaces was
firstDepth.secondDepth.Fubar
which contains its own classes (e.g. firstDepth.secondDepth.Fubar.someclass)
but I also had a ‘Fubar‘ class in the namespace
firstDepth.secondDepth
which textually resolves to the same as the Fubar namespace above.
Don’t do this
answered Oct 10, 2018 at 18:06
SeanSean
2,3962 gold badges15 silver badges17 bronze badges
This problem can also be caused if the assembly that you’re referencing isn’t actually built. For example, if your xaml is in Assembly1 and you’re referencing a class also in Assembly1, but that assembly has errors and isn’t building, this error will be shown.
I feel silly about it, but in my case I was tearing asunder a user control and had all sorts of errors in the related classes as a result. As I was attempting to fix them all I started with the errors in question, not realising that xaml relies on built assemblies to find these references (unlike c#/vb code which can work it out even before you build).
answered Dec 14, 2018 at 0:21
kad81kad81
10.6k3 gold badges39 silver badges44 bronze badges
I get this problem all the time. My views are in a WPF Custom Control Library project (a variant on Class Library). I can reference pre-built assemblies, but cannot reference any code in another project of the same solution. As soon as I move the code to the same project as the xaml it’s recognized.
answered Mar 12, 2019 at 16:53
user1040323user1040323
4694 silver badges11 bronze badges
This happened to me already twice in a complex WPF app, in it there are 4 multi platform projects, 1 shared project, 2 support libraries, and 1 test project..
This very specific XAML namespace error happened twice on very recently modified files on the Shared project. In both of my cases, it was a new c# file added with a repeating namespace entry;
Like namespace MyProgram.MyFolder.MyProgram.MyFolder
I double pasted it once by mistake, and once it was due to JetBrains Rider double pasting the namespace. (If you ever rename a project in Rider, it time to time starts double pasting namespaces on new file creations, especially on Shared projects..). These c# files with repeating namespaces were then called in the ViewModels where XAML files were referencing to. Well you then get these unrelated and misleading errors, you can have a problem with one file, all your Xaml files will start erroring out eventually.
Anyways, if you get these kind of errors, it’s most of the time an issue on a very newly added file or code change. My suggestions would be to look at your very recent changes.
answered Jun 17, 2020 at 19:43
Ali HusAli Hus
2554 silver badges10 bronze badges
1
If non of the answers worked
For me was .Net Framework version compatibility issue of the one i’m using was older then what is referencing
From properties => Application then target framework
answered Jul 6, 2020 at 16:18
VB.NET does not automatically add the Namespace information based on the folder structure as it does in C#. I think I am going through the same tutorial as you (Teach Yourself WPF in 24 Hours), and doing the same conversion to VB.
I found you have to manually add the Namespace information to Both the XAML Class and the XAML.VB code behind to be able to use the Namespaces as described in the book. Even then, VB doesn’t automatically Assign the Namespace to the Assembly as it does in VB.
There is another article here that shows how to include this in your project templates so it does build the Namespace information automatically — Automatically add namespace when adding new item
answered Sep 30, 2013 at 14:57
JeremyJeremy
5044 silver badges15 bronze badges
In the solution property page, check the platform of the assembly that contains «UpdatingMediaElement» and the assmeblies that contain any of the superclasses and interfaces from which «UpdatingMediaElement» subclasses or implements. It appears that the platform of all these assemblies must be «AnyCPU».
answered Sep 14, 2014 at 21:56
jgongjgong
6611 gold badge6 silver badges6 bronze badges
Another possible cause: A post-build event is removing the project DLL from the build folder.
To clarify: WPF designer may report «The name XXX does not exist in the namespace…», even when the name does exist in the namespace and the project builds and runs just fine if a post-build event removes the project DLL from the build folder (binDebug, binRelease, etc.). I have personal experience with this in Visual Studio 2015.
answered Feb 15, 2016 at 20:12
R.T.R.T.
395 bronze badges
Ok, so none of these tips worked for me, unfortunately. I was able to eventually solve the issue. It seems that Visual Studio does not play nicely with network drives. I solved this issue by moving the project from the shared drive to my local and recompiled. No more errors.
answered Jul 28, 2016 at 18:46
Noahm888Noahm888
1131 gold badge1 silver badge10 bronze badges
1
Adding to the pile.
Mine was the assembly name of the WPF application was the same assembly name as a referenced dll. So make sure you don’t have duplicate assembly names in any of your projects.
answered Mar 1, 2017 at 18:10
CeresCeres
3,4463 gold badges17 silver badges23 bronze badges
I had the solution stored on a network share and every time I opened it I would get the warning about untrusted sources. I moved it to a local drive and the «namespace does not exist» error went away as well.
answered May 10, 2017 at 22:05
Kevin S. MillerKevin S. Miller
8931 gold badge9 silver badges21 bronze badges
Using VS2012 working on a VB.NET WPF application. I have a simple MusicPlayer tutorial app I am using to learn WPF. I am converting a C# version of the tutorial to VB.NET step by step.
It has 2 classes in the app that are both under the same namespace. I am able to reference the namespace in the XAML but when I try to reference the class object in XAML I get an error and I am not able to compile.
Strange thing is that the IntelliSense works fine with both referencing the namespace via the xmlns:c= tag and also when typing the class object using <c:
But the object is underlined and errors are generated trying to build or work in the designer.
The .vb class files are in a folder called Controls. The Main project Root Namespace is intentionaly left blank. The class is coded like this…
Namespace MusicPlayer.Controls
Public Class UpdatingMediaElement
.... code here
End Public
End Namespace
The xaml looks like this
(namespace defined in the <Window > tag
xmlns:c="clr-namespace:MusicPlayer.Controls"
(object defined in a <Grid> )
<c:UpdatingMediaElement Name="MyMediaElement" />
(error displayed)
The name «UpdatingMediaElement» does not exist in the namespace «clr-namespace:MusicPlayer.Controls».
Not sure what is wrong or how to fix it?
asked Feb 2, 2013 at 19:40
4
When you are writing your wpf code and VS tell that «The name ABCDE does not exist in the namespace clr-namespace:ABC». But you can totally build your project successfully, there is only a small inconvenience because you can not see the UI designing (or just want to clean the code).
Try to do these:
-
In VS, right click on your Solution -> Properties -> Configuration Properties
-
A new dialog is opened, try to change the project configurations from Debug to Release or vice versa.
After that, re-build your solution. It can solve your problem.
answered Aug 1, 2014 at 11:07
Toan NCToan NC
2,8501 gold badge13 silver badges6 bronze badges
26
If the assembly is different from the namespace in which your class is contained, you have to specfiy it explicitly.
ex:-
xmlns:Local="clr-namespace:MusicPlayer.Controls;assembly=MusicPlayer"
slavoo
5,64864 gold badges36 silver badges39 bronze badges
answered Apr 1, 2013 at 11:35
5
In my case it was because of other compile errors. When other errors have been solved this seemingly related error was also removed from the list. Specially the errors at the bottom of the errors list and on pages you have recently changed.
So do not pay attention to this error directly and focus on other errors at first.
Bugs
4,4919 gold badges32 silver badges41 bronze badges
answered May 28, 2013 at 9:48
ImanIman
17.4k6 gold badges79 silver badges89 bronze badges
5
I’ve seen this issue go away by clearing the Xaml Design Shadow Cache. I had the issue with Visual Studio 2015 Update 1.
In Visual Studio 2015 the Cache is located here:
%localappdata%MicrosoftVisualStudio14.0DesignerShadowCache
Process:
- Right-Click on the solution in the Solution Explorer and Choose «Clean Solution»
- Shutdown Visual Studio
- Delete the ShadowCache folder
- Reopened the Visual Studio project
- Rebuild the solution
And voila no more namespace errors.
answered Mar 3, 2016 at 18:44
1iveowl1iveowl
1,5621 gold badge19 silver badges30 bronze badges
6
Try changing the build target platform to x86 and building the project.
I noticed via Subversion that I apparently changed the project build Platform target to x64. This was the only change I had made. After making that change, the code was working for a short while before it started showing the same error you experienced. I changed the platform target to x86 to test and suddenly my designer was working again. Subsequently, I changed it back to x64, and the problem has disappeared completely. I suspect that the designer builds some kind of cached code in x32 and changing the x64 build platform breaks it when you make code changes.
answered Dec 26, 2014 at 22:00
teynonteynon
7,19110 gold badges61 silver badges101 bronze badges
7
Maybe another solution for when the project compiles but the XAML error is showing :
- In solution explore, on the project node that contains the xaml
- Right-click on the project and choose ‘Unload Project’
- Right-click on the project and choose ‘Reload Project’
Make sure that your project is still choosen as «startup project». If not : - Right-click on the project and choose ‘Set as startup project’
No need to rebuild, or close visual studio.
answered Mar 24, 2017 at 14:33
SimonSimon
2,1671 gold badge21 silver badges24 bronze badges
0
Jesus… This is still a problem five years later in Visual Studio 2017. Since I’m new to WPF, I was sure the problem was somehow me, but no, everything compiled and ran correctly.
I tried rebuilding, cleaning and rebuilding, switching between x86/x64 output, rebooting Windows, cleaning the ShadowCache folder, adding «;assembly={my main assembly name}» to the XML namespace declaration, nothing worked! The single thing that did:
Put my static class of Commands (in my case the deal was about making the design discover my WPF Commands) in its separate assembly and changing the assembly name to that one’s instead.
answered Dec 15, 2017 at 9:36
JonasJonas
1,1321 gold badge16 silver badges25 bronze badges
Dunno if this will help anyone else
I’m new to WPF and still a novice with VB.net — so I was assuming that getting this error was being caused by me doing summit silly…….. suppose I was really! I’ve managed to get rid of it by moving my project from a shared drive to one of my local drives.
Error’s disappeared, project compiles perfectly no further issues — yet. Looks like VS2015 still has problems with projects held on a shared drive.
answered Mar 14, 2016 at 18:12
Supa StixSupa Stix
1442 silver badges4 bronze badges
2
I had this problem recently using VS 2015 Update 3 for my WPF project in .NET 4.6.2. The copy of my project was in a network folder, I moved it locally and that solved the problem.
This may solve other sort of problems, as it looks like VS 2015 doesn’t like network paths. Another issue that is a big problem for them is syncing git repositories if my project is in a network path, also solved by moving it locally.
answered Sep 28, 2016 at 10:37
gbdavidgbdavid
1,61917 silver badges38 bronze badges
I went through all the answers and none helped me. Finally was able to solve it by myself, so presenting the answer as it might help others.
In my case, the solution had two projects, one containing the models (say the project and assembly name was Models) and another containing the views and view models (as per our convention: project, assembly name and default namespace were Models.Monitor). The Models.Monitor referred Models project.
In the Models.Monitor project, in one of the xaml I included the following namespace:
xmlns:monitor=»clr-namespace:Models.Monitor»
I suspect that MsBuild and Visual Studio then were erroring out as they were trying to find a ‘Monitor’ type in the assembly ‘Models’. To resolve I tried the following:
- xmlns:monitor=»clr-namespace:Models.Monitor;assembly=» — which is valid if the namespace is in same assembly as per https://msdn.microsoft.com/en-us/library/ms747086(v=vs.110).aspx
- also tried the explicit namespace declaration:
xmlns:monitor=»clr-namespace:Models.Monitor;assembly=Models.Monitor»
Neither of the above worked.
Finally I gave up, and as a work around moved the UserControl I was trying to use to another namespace: ‘ModelsMonitor’. I was able to compile fine after that.
answered Jun 2, 2017 at 19:07
0
I’m also having a lot of trouble with this one! Intellisense helps me complete the namespace and everything, but the compiler cries. I’ve tried everything I found in this and other threads. However in my case what helped in the end was writing something like this:
xmlns:util="clr-namespace:LiveSpielTool.Utils;assembly="
Leaving the assembly name empty. No idea why. But it was mentioned here. I must add I am developing an assembly, so the assembly attribute might make sense. But entering the assembly name did not work. So weird.
StayOnTarget
11k10 gold badges49 silver badges75 bronze badges
answered Nov 26, 2018 at 12:10
I had the same problem , and in my case the the Markup Design View asked me to rebuild the solution and did not show me the form layout with this message:
Design view is unavailable for x64 and ARM target platforms, or Build the Project to update Design view.
It does not get solved by rebuilding the solution (neither the design view nor the «The name does not exist in the namespace» error)
I think it was because I had played with the settings on Solution -> Properties > Configuration Properties
I finally resolved the problem with 2 jobs:
- Checking all check boxes on Build Column of the page: Solution -> Properties -> Configuration Properties
- Changing the solution configurations from Debug to Release or vice versa.
I think it’s a bug in Visual Studio2012 Update 2.
amhed
3,6392 gold badges30 silver badges56 bronze badges
answered Jun 2, 2013 at 13:55
Ehsan AbidiEhsan Abidi
8918 silver badges24 bronze badges
The same problem plagues Visual Studios 2013, Service Pack 4.
I also tried it with Visual Studios 2015 Preview with the same results.
It’s just a limitation of the WPF visualizer which the Visual Studios team hasn’t fixed.
As proof, building in x86 mode enables the visualizer and building in x64 mode disables it.
Strangely enough intellisense works for Visual Studios 2013, Service Pack 4.
answered Jan 15, 2015 at 23:24
In my case the problem was due to some phantom files under the project’s obj directory. The following fixed the issue for me:
- Clean project
- Exit VS
- rm -rf /obj/*
- Invoke VS and rebuild
answered Apr 30, 2019 at 20:30
In my case, it was just a weird bug.
I had the class I was trying to use in my namespace however Visual Studio kept throwing an error saying the class did not exist in the given namespace.
What I did to fix it was really silly but worked like a charm.
I commented out all the lines of code where I was trying to use the class, cleaned the build, rebuilt and the project was up and running.
Then I just uncommented the lines of code I had commented earlier and well, Visual Studio was no longer throwing me any errors.
Rebuild again and you are ready to go.
answered Jun 5, 2022 at 3:45
Looks like this problem may be solved through a variety of «tricks.»
In my case, I had been building/rebuilding/cleaning the entire solution, instead of just the project that I was working on within the solution. Once I clicked «Build [my project],» the error message went away.
answered Jul 25, 2016 at 23:40
Try verifying your assembly references. If you have a yellow exclamation mark on the project references there’s a problem there and you’ll get all kinds of errors.
If you know the project reference is correct, check the Target framework. For instance, having a project using the 4.5 framework reference a project with 4.5.2 framework is not a good combination.
answered Jul 22, 2016 at 7:44
1
The solution for me was to unblock the assembly DLLs. The error messages you get don’t indicate this, but the XAML designer refuses to load what it calls «sandboxed» assemblies. You can see this in the output window when you build. DLLs are blocked if they are downloaded from the internet. To unblock your 3rd-party assembly DLLs:
- Right click on the DLL file in Windows Explorer and select Properties.
- At the bottom of the General tab click the «Unblock» button or checkbox.
Note: Only unblock DLLs if you are sure they are safe.
answered Feb 21, 2017 at 15:15
JordanJordan
9,5229 gold badges71 silver badges138 bronze badges
1
In my case, the user control was added to the main project. I tried various solutions above to no avail. Either I would get Invalid Markup but the solution would compile and work, or I would add the
xmlns:c=»clr-namespace:MyProject;assembly=MyProject» and then the markup would show, but I would get a compile error that the tag does not exist in the XML namespace.
Finally, I added a new WPF User Control Library project to the solution and moved my user control from the main project into that one. Added the reference and changed the assembly to point to the new library and finally the markup worked and the project compiled without error.
answered Apr 3, 2017 at 15:59
Kevin CookKevin Cook
1,9021 gold badge17 silver badges16 bronze badges
In my case I had a namespace and class spelled exactly the same, so for example, one of my namespaces was
firstDepth.secondDepth.Fubar
which contains its own classes (e.g. firstDepth.secondDepth.Fubar.someclass)
but I also had a ‘Fubar‘ class in the namespace
firstDepth.secondDepth
which textually resolves to the same as the Fubar namespace above.
Don’t do this
answered Oct 10, 2018 at 18:06
SeanSean
2,3962 gold badges15 silver badges17 bronze badges
This problem can also be caused if the assembly that you’re referencing isn’t actually built. For example, if your xaml is in Assembly1 and you’re referencing a class also in Assembly1, but that assembly has errors and isn’t building, this error will be shown.
I feel silly about it, but in my case I was tearing asunder a user control and had all sorts of errors in the related classes as a result. As I was attempting to fix them all I started with the errors in question, not realising that xaml relies on built assemblies to find these references (unlike c#/vb code which can work it out even before you build).
answered Dec 14, 2018 at 0:21
kad81kad81
10.6k3 gold badges39 silver badges44 bronze badges
I get this problem all the time. My views are in a WPF Custom Control Library project (a variant on Class Library). I can reference pre-built assemblies, but cannot reference any code in another project of the same solution. As soon as I move the code to the same project as the xaml it’s recognized.
answered Mar 12, 2019 at 16:53
user1040323user1040323
4694 silver badges11 bronze badges
This happened to me already twice in a complex WPF app, in it there are 4 multi platform projects, 1 shared project, 2 support libraries, and 1 test project..
This very specific XAML namespace error happened twice on very recently modified files on the Shared project. In both of my cases, it was a new c# file added with a repeating namespace entry;
Like namespace MyProgram.MyFolder.MyProgram.MyFolder
I double pasted it once by mistake, and once it was due to JetBrains Rider double pasting the namespace. (If you ever rename a project in Rider, it time to time starts double pasting namespaces on new file creations, especially on Shared projects..). These c# files with repeating namespaces were then called in the ViewModels where XAML files were referencing to. Well you then get these unrelated and misleading errors, you can have a problem with one file, all your Xaml files will start erroring out eventually.
Anyways, if you get these kind of errors, it’s most of the time an issue on a very newly added file or code change. My suggestions would be to look at your very recent changes.
answered Jun 17, 2020 at 19:43
Ali HusAli Hus
2554 silver badges10 bronze badges
1
If non of the answers worked
For me was .Net Framework version compatibility issue of the one i’m using was older then what is referencing
From properties => Application then target framework
answered Jul 6, 2020 at 16:18
VB.NET does not automatically add the Namespace information based on the folder structure as it does in C#. I think I am going through the same tutorial as you (Teach Yourself WPF in 24 Hours), and doing the same conversion to VB.
I found you have to manually add the Namespace information to Both the XAML Class and the XAML.VB code behind to be able to use the Namespaces as described in the book. Even then, VB doesn’t automatically Assign the Namespace to the Assembly as it does in VB.
There is another article here that shows how to include this in your project templates so it does build the Namespace information automatically — Automatically add namespace when adding new item
answered Sep 30, 2013 at 14:57
JeremyJeremy
5044 silver badges15 bronze badges
In the solution property page, check the platform of the assembly that contains «UpdatingMediaElement» and the assmeblies that contain any of the superclasses and interfaces from which «UpdatingMediaElement» subclasses or implements. It appears that the platform of all these assemblies must be «AnyCPU».
answered Sep 14, 2014 at 21:56
jgongjgong
6611 gold badge6 silver badges6 bronze badges
Another possible cause: A post-build event is removing the project DLL from the build folder.
To clarify: WPF designer may report «The name XXX does not exist in the namespace…», even when the name does exist in the namespace and the project builds and runs just fine if a post-build event removes the project DLL from the build folder (binDebug, binRelease, etc.). I have personal experience with this in Visual Studio 2015.
answered Feb 15, 2016 at 20:12
R.T.R.T.
395 bronze badges
Ok, so none of these tips worked for me, unfortunately. I was able to eventually solve the issue. It seems that Visual Studio does not play nicely with network drives. I solved this issue by moving the project from the shared drive to my local and recompiled. No more errors.
answered Jul 28, 2016 at 18:46
Noahm888Noahm888
1131 gold badge1 silver badge10 bronze badges
1
Adding to the pile.
Mine was the assembly name of the WPF application was the same assembly name as a referenced dll. So make sure you don’t have duplicate assembly names in any of your projects.
answered Mar 1, 2017 at 18:10
CeresCeres
3,4463 gold badges17 silver badges23 bronze badges
I had the solution stored on a network share and every time I opened it I would get the warning about untrusted sources. I moved it to a local drive and the «namespace does not exist» error went away as well.
answered May 10, 2017 at 22:05
Kevin S. MillerKevin S. Miller
8931 gold badge9 silver badges21 bronze badges
After installing the Template10 upgrade, in a File->New project I named T10Minimal1.1 I get this error. I have this same error in a previous Template10 project with just the Interaction namespace error.
I’ve updated all my tools extensions and NuGets. Closed the solution, opened cleaned and rebuilt. The app appears to work correctly.
When I ‘Design in blend’ the project opens with no errors and the xaml designer renders.
In VS I open the DetailsPage.xaml that appears to have the same namespaces. Designer renders and no errors are shown.
I am going to guess that this is a copy/paste inheritance error. Ha! You need to do two things. The first is to make sure you have referenced the Behaviors SDK in your project (right-click References, select Windows/Extensions/Behaviors SDK) and then add this to your xmlns at the top of your page:
xmlns:Behaviors="using:Template10.Behaviors"
xmlns:Core="using:Microsoft.Xaml.Interactions.Core"
xmlns:Interactivity="using:Microsoft.Xaml.Interactivity"
«After installing the Template10 upgrade, in a File->New project I named T10Minimal1.1 I get this error»
It wasn’t a copy paste situation. It was file new Template10 Minimal project.
x:Class="Sample.Views.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Behaviors="using:Template10.Behaviors"
xmlns:Core="using:Microsoft.Xaml.Interactions.Core"
xmlns:Interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:controls="using:Template10.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Sample.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="using:Sample.ViewModels" mc:Ignorable="d">
What’s with this yellow caution indicator? Is there a uwp windows 10 version of BehaviorsXamlSDKManaged? This one targets windows 8.1 Seems I’d get a warning or error from VS on this.
Also curious about the uppercase for the Behaviors, Core and Interactivity. Although I might prefer upper case isn’t it a generally accepted .XAML convention to use lower case?
xmlns:Behaviors="using:Template10.Behaviors"
xmlns:Core="using:Microsoft.Xaml.Interactions.Core"
xmlns:Interactivity="using:Microsoft.Xaml.Interactivity"
I am having the same issue, but in main page. Designer crashes, but the project compiles despite errors.
This is a screen by @darenm so the issue must be wide.
The screen is from «Microsoft: DEV209.1x Developing Windows 10 Universal Apps — Part 1» and we are at least two people there with the same problem.
Acknowledged. Chasing it today.
Now I understand what your issue is.
Good news. The Behaviors SDK has a warning icon next to it because Visual Studio detects incompatibilities with UWP that in practice do not impact anything for us (developers). For what we use it for — behaviors — it is perfect. My screen also shows the warning, too.
To be clear this is a WARNING and not an ERROR.
The reason your designer is failing is something else. The reason might be simply because the designer is a little unstable at this point and requires a restart every day. Then again, it might be because your XAML has an error. It’s impossible to diag that at this point. But the Behavior SDK warning is okay.
Clean installed Windows 10, Visual Studio 2015 Enterprise — clean, not modified minimal template and the same thing happens to me so I guess it can’t be an error in XAML — Maybe it is «a little unstable designer» — nevertheless it compiles and works so it’s okay for now..
I’m facing the same issue here.
It seems that you target ARM.
Try to set to Any CPU when designing, rebuild and it should be OK
Solution: uninstall Template10 NuGet package, Clean solution and install it back.
Error reproduced here: http://1drv.ms/1Gpfd60
P.S.: namespaces should be a lower case anyway,
xmlns:Behaviors, Core, Interactivity
Having the same issue.
What worked for me was MichaelPetronlis’s solution. Thanks!
A quick note: I had to switch to Debug x64 to get the designer loading in VS2015.
For Blend however, I would still get the same error. Debug x86 got the Blend designer to
load there 
So try out various configurations in both(!) VS and Blend if one or both of your designers are unhappy for some reason.
I get this error, i.e.
«The name ‘Interaction’ does not exist in the namespace «using:Microsoft.Xaml.Interactivity»
in many files in the XAMLBehaviorsSample project. I had set the target to x86 (from Arm, which was what it started as), but otherwise did not change anything. It compiles and runs though.
Make sure you do not use Behaviors SDK (XAML) version 12.0, which is for Windows 8.1.
What you need is the new open-sourced XamlBehaviors. You can include it by adding Microsoft.Xaml.Behaviors.Uwp.Managed to your project.json.
{
"dependencies": {
"Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0",
"Microsoft.Xaml.Behaviors.Uwp.Managed": "1.0.3",
"Template10": "1.1.3",
"Newtonsoft.Json": "8.0.2"
},
Thanks Justin, the project did have the right version of XamlBehaviors — 1.0.3 was listed in the .json file (the XAMLBehaviorsSample actually came from the UWP XamlBehaviors project on Github). I did fix the problem though, in Solution Explorer there were references to Microsoft.Xaml.Interactivity and Microsoft.Xaml.Interactions.Core; they both had the exclamation mark beside them so I removed them, then added the references back from Object Browser (v1.0.3.0 req’d for Win 10 UWP as opposed to the identically named v12.0.0.0 which supports Win 8.1). They do not show up in the project’s References list now, but I don’t get those error messages in the XAML file.
Haven’t managed to remove the error from my own UWP project yet though; there are no references to .Interactivity or .Interactions in my project References to remove. Adding v1.0.3.0 of both of them from Object Browser does let it compile and run though (and it behaves as expected), but in the XAML file it shows them as errors.
Thanks!
So, turns out I just needed to restart Visual Studio to get it to stop giving me «The name ‘Interaction’ does not exist in the namespace» errors for the XAML file. When in doubt, reboot! 
@TCPhelps This worked for me as well! Thanks!!
@TCPhelps Thanks!!! This worked for me too. Additionally I have to manually delete the bin & obj folder and rebuild it. 😄
In my project I am having a dockpanel with two panes inside. All views give me errors, still the project can be built…
Here the structure of my project:
Stepper
|_ Commands
|_ Models
|_ ViewModels
|_ PaneHeaderControlViewModel.cs
|_ PaneHeaderRulesViewModel.cs
|_ Views
|_ PaneHeaderControlView.xaml
|_ PaneHeaderRulesView.xaml
_ StepperDockpane.xaml
_ StepperDockpaneViewModel.cs
Here the content of StepperDockpane.xaml
<UserControl x:Class="Stepper.StepperDockpaneView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:ui="clr-namespace:Stepper"
xmlns:extensions="clr-namespace:ArcGIS.Desktop.Extensions;assembly=ArcGIS.Desktop.Extensions"
xmlns:controls="clr-namespace:ArcGIS.Desktop.Framework.Controls;assembly=ArcGIS.Desktop.Framework"
xmlns:viewModel="clr-namespace:Stepper.ViewModels"
xmlns:view="clr-namespace:Stepper.Views"
mc:Ignorable="d"
d:DesignHeight="600" d:DesignWidth="300"
d:DataContext="{Binding Path=ui.StepperDockpaneViewModel}">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<extensions:DesignOnlyResourceDictionary Source="pack://application:,,,/ArcGIS.Desktop.Framework;componentThemesDefault.xaml"/>
</ResourceDictionary.MergedDictionaries>
<DataTemplate DataType="{x:Type viewModel:PaneHeaderRulesViewModel}">
<view:PaneHeaderRulesView />
</DataTemplate>
<DataTemplate DataType="{x:Type viewModel:PaneHeaderControlViewModel}">
<view:PaneHeaderControlView />
</DataTemplate>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<DockPanel Grid.Row="0" LastChildFill="False" KeyboardNavigation.TabNavigation="Local" Height="30" Margin="5,0">
<ListBox x:Name="primaryNavigator" DockPanel.Dock="Left"
Style="{DynamicResource Esri_ListBoxPanelIndicator}"
ItemsSource="{Binding PrimaryMenuList}"
SelectedIndex="{Binding SelectedPanelHeaderIndex, Mode=TwoWay}"
IsSynchronizedWithCurrentItem="True" />
<controls:BurgerButton DockPanel.Dock="Right"
ToolTip="{Binding BurgerButtonTooltip}"
PopupMenu="{Binding BurgerButtonMenu}"/>
</DockPanel>
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
<StackPanel>
<ContentPresenter Content="{Binding CurrentPage}"></ContentPresenter>
</StackPanel>
</ScrollViewer>
</Grid>
</UserControl>
Line 17 returns:
Error: Could not load file or assembly ‘ArcGIS.Desktop.Framework, Culture=neutral’ or one of its dependencies. The referenced file could not be found.
Line 34 returns:
Warning: The resource «Esri_ListBoxPanelIndicator» could not be resolved.
————————————
Here the relevant content of PaneHeaderRulesView.xaml
<UserControl x:Class="Stepper.Views.PaneHeaderRulesView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:extensions="clr-namespace:ArcGIS.Desktop.Extensions;assembly=ArcGIS.Desktop.Extensions"
xmlns:ui="clr-namespace:Stepper.Views"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:viewmodels="clr-namespace:Stepper.ViewModels"
d:DataContext="{d:DesignInstance Type=viewmodels:PaneHeaderRulesViewModel}"
mc:Ignorable="d"
d:DesignHeight="520" d:DesignWidth="300">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<extensions:DesignOnlyResourceDictionary Source="pack://application:,,,/ArcGIS.Desktop.Framework;componentThemesDefault.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
Line 16 returns:
Error: Could not load file or assembly ‘ArcGIS.Desktop.Framework, Culture=neutral’ or one of its dependencies. The referenced file could not be found.
————————————
Here the relevant content of PaneHeaderControlView.xaml
<UserControl x:Class="Stepper.Views.PaneHeaderControlView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:extensions="clr-namespace:ArcGIS.Desktop.Extensions;assembly=ArcGIS.Desktop.Extensions"
xmlns:editing="clr-namespace:ArcGIS.Desktop.Editing;assembly=ArcGIS.Desktop.Editing"
xmlns:ui="clr-namespace:Stepper.Views"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:viewmodels="clr-namespace:Stepper.ViewModels"
d:DataContext="{d:DesignInstance Type=viewmodels:PaneHeaderControlViewModel}"
mc:Ignorable="d"
d:DesignHeight="520" d:DesignWidth="300">
.
.
.
<editing:TableControl Grid.Row="2" x:Name="tableControl"
AutomationProperties.AutomationId="_tableControl"
HorizontalAlignment="Stretch"
TableContent="{Binding Path=TableContent}"
MinHeight="450"
MaxHeight="500"
RowContextMenu="{StaticResource StepperRowContextMenu}"
SelectedRowContextMenu="{StaticResource StepperRowContextMenu}"
ColumnContextMenu="{StaticResource StepperColumnContextMenu}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseDoubleClick">
<i:InvokeCommandAction Command="{Binding ZoomItemCommand}"/>
</i:EventTrigger>
<i:EventTrigger EventName="SelectedRowsChanged">
<i:InvokeCommandAction Command="{Binding GetSelectedRowCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</editing:TableControl>
Line 17 returns:
Error: XDG0008 The name «TableControl» does not exist in the namespace «clr-namespace:ArcGIS.Desktop.Editing;assembly=ArcGIS.Desktop.Editing».
I can clearly see in the Assembly Explorer of Visual Studio 2019 that ArcGIS.Desktop.Editing contains TableControl.
————————————
On top of all this is every reference a la Style=»{DynamicResource Esri_xxxx}» marked with a warning that the resource could not be resolved.
I am using Visual Studio version 16.11.1
.NET Framework version 4.8.03752
ArcGIS Pro SDK for .NET in version 2.8.0.29751
ArcGIS Pro SDK for .NET (Utilities) in version 2.8.0.29751
and the project has x64 as platform target.
Any help is appreciated.
— We are living in the 21st century.
GIS moved on and nobody needs a format consisting out of at least three files! No, nobody needs shapefiles, not even for the sake of an exchange format. Folks, use GeoPackage to exchange data with other GIS!


