Blazor: Problems with namespaces when same term is used before and after a dot

Viewed 493

I've a problem with Blazor when I have different projects having namespaces with the same term on different side of the dot(s), in my example frontend.project and project.data:

What I did:

  • Create a new solution with a blazor serverside project named frontend.project
  • Add a new class library, named project.data
  • On frontend.project, add reference to project.data
  • Open _Import.razor on frontend.project, add @using project.data

I'm getting the error: Error CS0234 The type or namespace name 'data' does not exist in the namespace 'frontend.project' (are you missing an assembly reference?)

adding @using project.data inside a .razor-file results in the same error

Also intellisense shows that the namespace is searched in frontend.project, despite having @using project.data:

enter image description here

on .cs / .cshtml.cs files, everything works fine as expected, only .razor-files are affected.

Tried on Visual Studio 16.7.7 / .NET 3.1.403

Here's a demo project on GitHub: https://github.com/Sabbi/blazor-namespace-issue

Any ideas how how to solve this without renaming the namespaces?

1 Answers

Try right-clicking your solution file in the Solution Explorer and press 'Sync Namespaces'.

Related