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

1

6

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?

Nebiim answered 4/11, 2020 at 10:9 Comment(2)
@Vencovsky the order of the using does not change anything - even with only @using project.data in _Imports.razor (or any other .razor-File), the error persists.Nebiim
The current project namespace project conflicts with the namespace of project.data.Rillis
P
-1

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

Pederasty answered 16/6, 2022 at 21:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.