1

I've been having a problem with Intellisense in Asp.Net Core and Blazor for months where it won't recognize a newly created class. I've read all the other answers about changing settings, Ctrl-J, and removing .vs folder, but none resolved the issue. Until today when I found the root.

Working in Blazor, I would create a new class <Bar /> and then try to call it from a parent <Foo /> Intellisense would mark it not found:

Error: Found markup element with unexpected name 'Bar'. If this is intended to be a component, add a @using directive for its namespace.

Of course, providing a fully qualified name did nothing to resolve the complaint. But, it compiles just fine. Clearly it is Intellisense that was doing the complaining, not the compiler. Aggravating but by no means a show stopper.

This morning, however, when I came back to my project (without shutting down or anything) <Bar /> was recognized by Intellisense. There appears to be some kind of periodic cache refresh. It would be nice to know how to force the refresh without drastic measures.

Then I made a copy of <Bar /> renamed it <BarBar />. Of course Intellisense didn't recognize it, barked at me, and I did have the correct page name of @page "/BarBar"

BDNTS
  • 63
  • 7

1 Answers1

2

ANSWER

I noticed scrolling through the Intellisense window something interesting:

Bar
Bar__Copy

Apparently, because I had copied Bar.razor, pasted it as Bar - Copy.razor, and then renamed it to BarBar.razor, and changed the page directive. Intellisense stuck with the initial parsing and ignored the changes. To resolve the problem, I simply deleted BarBar.razor, did an Add --> New --> Blazor Page Named it BarBar.razor, and copied the contents of Bar.razor across, correcting the @page directive. Intellisense is happy now.

I hope someone finds this useful.

BDNTS
  • 63
  • 7