Issue adding Security to Blazor Server Project

With version 1.4.0 of Blazor Studio installed, after creating a Blazor Server project, and scaffolding the database, the project runs fine. Then adding Security, selecting the Micrsoft Identity option, selecting the Register and Forgot Password options, the process does not Inject the Security Service or add the Profile click method.

See the attached screenshots.



Hi @ggrewe,

Just tested the same with 1.4.0 and everything went fine. You can try restarting RBS and adding security again.

@korchev Thanks for the quick response and on a Saturday! I have tried the process several times, thinking maybe it was the project name (which included a period) or the length of the path, but modifying either did not resolve the issue. I tried reinstalling the RSB and restarting my computer as well. The process completes without issue for a Web Assembly project.

The log file did not get uploaded with my original post; the process stops after the Migrations are created, and before the Identity tables are created. Here is the Exception in the log file:

[2023-02-25 08:50:50.508] [error] Error: System.NullReferenceException: Object reference not set to an instance of an object.
at Radzen.Server.CompilationExtensions.GetEntities(Compilation compilation)
at Radzen.Server.ProgramController.<>c.b__64_1(ProjectContext p)
at System.Linq.Enumerable.SelectManySingleSelectorIterator2.ToList() at Radzen.Server.ProgramController.<ListEntities>b__64_0() at Radzen.Server.LoggerExtensions.Measure[T](ILogger logger, String name, Func1 action)
at Radzen.Server.ProgramController.ListEntities()
at lambda_method252(Closure, Object, Object)
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.g__Awaited|8_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)

Hi @ggrewe,

This exception seems unrelated, unfortunately. I am not sure what can cause adding security to fail but it doesn't seem to be a new issue. Does it happen in a new project?

Hi Atanas,

Yes, it happens in any new Server project that I create, it works fine in any Web Assembly project.

After posting my reply with Exception information, I uninstalled RSB again, restarted the computer, reinstalled RSB, restarted the computer, then created and ran the project, closed RSB, opened RSB, added the data and ran the project, closed RSB, opened RSB, added Security, and the same error.

It is really a very basic project and only 18 tables in the database. If it will help, I can send you the database DDL and one of the Server projects.

Sure, you can send us the database DDL. Last thing you can try is to not generate any pages after inferring the database.

Thanks again Atanas,

I created a new database, thinking maybe it was because the database name had an underscore, and did not create any pages, the same error occurred. So strange. I will send an e-mail to info, attach the DDL and the current project.

I appreciate the help!

I was able to add security to your application without problems. The security service was injected as expected. Find the MainLayout attached.

Archive.zip (2.5 KB)

I will test on a different machine to see if it makes any difference.

I deleted the generated profile menu code and then added security after checking all options.

Thank you so much Atanas! I will setup a VM in AWS and see if the process is successful there, it just will not complete on my computer.

@korchev Atanas,

Thank you again for all your help!

I installed RSB on a VM in AWS and created the Blazor Server project without any issue. I downloaded the code to my local computer and is working well.

Next week I will take some time and see if I can dig into why the process fails on my computer and post back here.