18

So I'm working in VS12 on Windows 8, and hacking the ContosoCookbook code to make a different app. I'm trying to set up a "MainMenu.xaml" page and in I have:

        <CollectionViewSource
        x:Name="groupedItemsViewSource"
        Source="{Binding Groups}"
        IsSourceGrouped="true"
        ItemsPath="TopItems"
        d:Source="{Binding AllGroups, Source={d:DesignInstance Type=data:FlashCardDataSource, IsDesignTimeCreatable=True}}"/>

The error I'm getting is: The name "FlashCardDataSource" does not exist in the namespace "using:FlashCards.Data".

...but I don't understand how it doesn't. Where do I start looking? I'm new at XAML.

-Ken

Ken Cone
  • 460
  • 1
  • 4
  • 11
  • what is the `xmlns` you have in the `Page` of your app? It looks like a simple namespace issue around the sample data sources that come with the VS2012 templates. – Mark Aug 30 '12 at 03:36
  • No, sorry, not yet. I've put this app on the shelf for now, but when I get back to it in the next few weeks and I have the answer, I will post it. – Ken Cone Oct 10 '12 at 02:22
  • Same problem for me, except running on Win7. The application compiles, but the XAML designer throws a fit. The error message is just wrong; everything's where it's meant to be and works. – Tom W Nov 09 '12 at 16:42
  • Having the same issue here (win7, VS2012). Application compiles and the custom control renders, but the xaml designer keeps throwing a fit. (funnily enough, not where i define the namespace, but only where i actually *use* the namespace) – Timothy Groote Jan 16 '14 at 10:07
  • 1
    Update : it turns out Windows had blocked the .dll files. Opening the file properties of the affected files and manually unblocking each referenced DLL and their dependencies fixed the issue. – Timothy Groote Jan 16 '14 at 10:32

8 Answers8

19

If nothing else is possible, comment the lines which use the namespace, rebuild, and then build the full project again.

I also tried rebuilding the project, reopening Visual Studio. Nothing helped. I finally commented xaml, rebuilt the project, uncommented xaml and it finally worked! Strange issue.

Arman H
  • 5,488
  • 10
  • 51
  • 76
Maxiss
  • 986
  • 1
  • 16
  • 35
  • Wow, that did the trick. In my case it could not find types defined in the same project...Thanks a lot for the tip! The lesson: use VS after its 5th SP. – AlexeiOst Jan 09 '15 at 23:19
  • In my case, it was the `xmlns:local="clr-namespace:Foo.Bar"` line that I had to comment/uncomment to snap VS out of its func; *not* the line that referenced the `local` namespace and where the (incorrect) error was actually being flagged. – dlf Jun 16 '15 at 12:53
13

If cleaning and rebuilding does not help, try restarting Visual Studio. Worked for me.

ApoorvaJ
  • 830
  • 1
  • 7
  • 24
5

Generally this error is caused by one of the following:

  1. You haven't referenced the assembly that the class is in.
  2. You haven't updated the reference to the assembly after adding the class to it.
  3. You are referencing the wrong version of the assembly.
  4. You are referencing the .DLL file instead of the project (in the case where the project is part of your solution)
  5. There is a syntax error in the class you are referencing.
Captain Kenpachi
  • 6,960
  • 7
  • 47
  • 68
2

Did you try to rebuild your project? Maybe clean the project and rebuild again.

Junfeng Dai
  • 116
  • 2
  • I have tried that. Uninstalled the app, cleaned the solution and/or project. I have FlashCardDataSource as a public class and have a method of the same name. I don't know if I'm missing a reference or what I'm doing wrong yet. – Ken Cone Aug 30 '12 at 03:25
  • 2
    Had the same problem and after a lot of struggling I'm not sure if it was restarting the VS11, cleaning the project or temporarily removing mc:Ignorable="d" from the page that made the VS11 realize it actually existed. – Sami Rajala Oct 14 '12 at 11:04
  • I had this problem; tried cleaning, etc. But restarting VS fixed it for me – Gordon Slysz Apr 22 '14 at 18:31
2

Check every class and xaml file for namespaces (even in App.xaml and MainWindow.xaml). Make sure you are not confusing the x:Class in the top element of the file with a namespace. Sometimes it indeed looks like a bug, but it's just one namespace somewhere that's independent of everything else that mixes up everything.

QuantumHive
  • 5,613
  • 4
  • 33
  • 55
1

If you are certain the class is present in the right namespace, just right click on the project in VS and choose Unload. Then Reload the project. This makes it re-evaluate all the namespaces and was the only cure for the issue I've found (when it really persistently won't acknowledge you classes;)

0

In my case, I clean all the property value relative to the binding I assign by code in all class, then all become normal.

I think if giving value to the property that using in bindings at the same time in some wrong position in class will cause problem, so remove all the assignment code relative to the property may help.

yu yang Jian
  • 6,680
  • 7
  • 55
  • 80
0

None of the above worked for me, but simply adding another dummy class to the folder containing the class it claimed did not exist seemed to do the trick. Maybe it made VS have another look.

Tim
  • 1,108
  • 13
  • 25