Ibraheem Ibraheem - 1 year ago 234
C# Question

WPF: The name does not exist in the namespace

I am building a C#/WPF application using VS2013, and I have the following class definition (in the same assembly of the running application):

namespace MyNamespace
public class MyKey
public MyKey() { }
public string name = "";

In MainWindow.xaml I have:

<Window x:Class="MyNamespace.MainWindow"
Title="MainWindow" Height="350" Width="525" WindowState="Maximized" WindowStyle="None">
<local:MyKey x:Key="key" />

VS keeps reporting that

The name "MyKey" does not exist in namespace

Any ideas?

P.S. I tried the following solutions (from already posted questions in stackoverflow) but none of them worked:

  1. Moving the class to a different namespace, then using the new namespace in xaml reference

  2. Restarting VS and cleaning/rebuilding the solution

  3. cleaning the solution then renaming its folder then building the solution again

  4. changing the reference to:


Edit: Additional info: The target architecture: X64, target framework: .Net 4.5

Answer Source

One common solution to this known VS bug that you haven't specified as having tried is changing the build target platform.

  1. If your current build target platform is x64, change to x86. If it's currently x86, change to x64.

  2. Clean and Build solution for new target platform.

  3. Change back to desired target platform and re-build.