1
votes

I have a Blazor component library, which contains a few classes and Blazor components.

I'm trying to reference a Blazor component from within a regular C# class, but I'm getting weirdness happening.

If I reference it where I expect it to be, it all compiles and runs fine

ModalDialogResult result = await ShowDialogAsync<LiquidTechnologies.Blazor.ModalDialog.Components.MessageBoxForm>(title, options, parameters);

But it reports the intellisense error

CS0234 The type or namespace name 'MessageBoxForm' does not exist in the namespace 'LiquidTechnologies.Blazor.ModalDialog.Components' (are you missing an assembly reference?)

It also failed to build in the GitHub Continuous integration environment (with the same intellisense error).

If I use the class name the intellisense finds (__generated__MessageBoxForm), I can't build it in Visual Studio 2019.

enter image description here

Arrrrhhh...

The project is in GitHub at blazor-modal-dialog. The issue is in the file blazor-modal-dialog/src/LiquidTechnologies.Blazor.ModalDialog/Services/ModalDialogService.cs

Looks similar to https://github.com/aspnet/AspNetCore/issues/12446

1
I looked at your code but could not see a Components namespace? - Quango
Sorry, I'm new to git, I'd been trying a few things and hadn't pushed my latest updates (I'd renamed Pages to Components). - Sprotty
First thing I'd try is Clean solution, comment out your code that's failing and try to build - see if there are other errors causing it - Quango
I think this is a bug in the VS blazor tooling, possibly because I'm running some Microsoft Preview code. I've managed to get it building in GitHub using runs-on: windows-latest in the YAML. See github.com/aspnet/AspNetCore/issues/15069 - Sprotty

1 Answers

2
votes

When you move or rename a component, Blazor has a bug (a very annoying one) still unresolved at the time I'm writing this. To solve, first of all try cleaning the solution and doing a solution Rebuild (building is not enought, rebuild is mandatory). Sometimes you'll also need to manually delete the obj and bin folders of the Blazor project before rebuilding the solution, and as a last attempt, you should try closing and restarting Visual Studio and then rebuild the solution. This should solve the issue. Otherwise, there could be some different reason, i.e. you're misspelling something or you're omitting the using namespace.