Error in Using references with Blazor Client

23 views Asked by At

In a blazor Web Assembly app, I have the following structure (simplified to the useful ones, see below). I want to make reference in (APP.Client)/Pages/_import.razor to APP.Components.Pages.MyPage for using its class from (APP.Client)/Pages/MyComponentUsingMyClass, but whenever I add "@using APP.Components" in _import, it is not working. While the exact same reference is known in APP/Components/Pages/_import.razor. Could you please help me clarify?

APP
-APP
--bin
--Components
---Layout
----MainLayout.razor
----MainLayout.razor.css
----NavMenu.razor
----NavMenu.razor.css
---Pages
----MyPage.razor
----Home.razor
----Error.razor
---_Imports.razor
---App.razor
---Routes.razor
--Data
--obj
--Properties
---launchSettings.json
--wwwroot
---bootstrap
----bootstrap.min.css
----bootstrap.min.css.map
---app.css
--Program.cs
-Client
--bin
--obj
--Pages
---MyComponentUsingMyClass.razor
---Home.razor
---Error.razor
---_Imports.razor
--wwwroot
--Program.cs
1

There are 1 answers

1
jepozdemir On

In your _import.razor file located in (APP.Client)/Pages, make sure you're referencing the correct namespace for the component you want to use.

I mean, if the namespace where MyPage resides is APP.Components.Pages, then your import statement should look like this:

@using APP.Components.Pages