Monday, July 14, 2014

Resolving the error "The name xxx does not exist in the namespace "clr-namespace:XXX" in Visual Studio 2012 for Windows Phone

In Windows Phone 8 development, it is possible to use the local project's public classes in a XAML file. But the local project's namespace has to be included in the XAML file by typing in the following:
xmlns:local="clr-namespace:Binding".
Here Binding refers to the namespace used by the class in the local project I want to use.

Then to use the local namespace in the XAML file to declare a class, I should do the following:
<local:MyData x:Key="MyData"
AppTitle="Real Estate Explorer" />

Everything looks fine, but the Visual Studio Intellisense underlines the local:MyData reference with the following error message:
The name "MyData" does not exist in the namespace "clr-namespace:Binding"

An example is shown below:

I could not figure out how to resolve the error; I did everything as described in the documentation. Eventually, I did a Build Solution (F7) on the project. After that, Visual Studio did not complain about the namespace anymore, as shown in the screenshot below.
 

1 comment:

Unknown said...

I had this problem and nothing seemed to work. Then I downloaded the latest .Net Framework and installed. After Setting the Target Framework to the latest, The problem was solved.

I'm very new to DotNet and learning WPF using Visual Studio 2017 Community edition. The DOtNet Framework giving me trouble was 4.6.1. Then After changing to .NetFramework 4.8 , my problem was solved.