Security errors?

Using Studio 1.49.1, I chose security/aszure ad and copied over my tenant/client id's. Then, when I tried to compile it, I get this:

The name 'ProfileMenuClick' does not exist in the current context
The name 'Security' does not exist in the current context
The name 'Security' does not exist in the current context

This is a brand new application, and i have made no changes yet? Have I missing something?

Does restarting Radzen Blazor Studio help? Is the application running successfully?

So, I restarted the studio, and created a brand new application. I added a blank test page. Ran it and everything worked fine. Then I went to SECURITY and chose "Azure AD" and filled in the appropriate ID info. When I clicked finish, it processed for a bit and now the blank test page says "application does not build" so I can't see the page? I also have these errors in the output window:

c:\dev\test\ssoTest2\Components\Layout\MainLayout.razor(14,50): error CS0103: The name 'Security' does not exist in the current context
c:\dev\test\ssoTest2\Components\Layout\MainLayout.razor(14,86): error CS0103: The name 'ProfileMenuClick' does not exist in the current context
c:\dev\test\ssoTest2\Components\Layout\MainLayout.razor(19,30): error CS0103: The name 'Security' does not exist in the current context

And no, the application will not build and restarting didn't help? So the first error shows this line in the razor file:

But in the CS file, here's the generated code:

public partial class MainLayout
{
[Inject]
protected IJSRuntime JSRuntime { get; set; }

 [Inject]
 protected NavigationManager NavigationManager { get; set; }

 [Inject]
 protected DialogService DialogService { get; set; }

 [Inject]
 protected TooltipService TooltipService { get; set; }

 [Inject]
 protected ContextMenuService ContextMenuService { get; set; }

 [Inject]
 protected NotificationService NotificationService { get; set; }

 private bool sidebarExpanded = true;

 void SidebarToggleClick()
 {
     sidebarExpanded = !sidebarExpanded;
 }

}

I don't see a ProfileMenuClick function?? So I added an empty ProfileMenuClick function, and that fixed that error. The other error is the Security object is missing from the generated code? I don't see any injected Security type object in the generated code here?

So I added this:

    [Inject]
    SecurityService Security { get; set; }

and now the app will build and run? Looks like the code generator is missing generating some boilerplate code perhaps??

Hi @terryfryar,

Thank you for elaborating. We will investigate by reproducing the same steps.

I tested the following setup and it worked without problems (it did generate ProfileMenuClick in MainLayout.razor.cs):

  1. Create a new .NET 9 Blazor app with server rendering called AzureAdServer
  2. Add a new empty page called Test
  3. Add Azure AD security to the app.

Here is how the MainLayout.razor file looks after that:

namespace AzureAdServer.Components.Layout
{
    public partial class MainLayout
    {
        [Inject]
        protected IJSRuntime JSRuntime { get; set; }

        [Inject]
        protected NavigationManager NavigationManager { get; set; }

        [Inject]
        protected DialogService DialogService { get; set; }

        [Inject]
        protected TooltipService TooltipService { get; set; }

        [Inject]
        protected ContextMenuService ContextMenuService { get; set; }

        [Inject]
        protected NotificationService NotificationService { get; set; }

        private bool sidebarExpanded = true;

        [Inject]
        protected SecurityService Security { get; set; }

        void SidebarToggleClick()
        {
            sidebarExpanded = !sidebarExpanded;
        }

        protected void ProfileMenuClick(RadzenProfileMenuItem args)
        {
            if (args.Value == "Logout")
            {
                Security.Logout();
            }
        }
    }
}

Am I missing some step?

Mine does not look like that?? And I have done the same steps? What version of Blazor Studio are you using? My version is 1.49.1

I have tested with the latest official version which is 1.49.1






So the last image is what happened after adding security. I don't see any change from the first one?? Where is the added code? I have no Security injection and no ProfileMenuClick??

What am I doing wrong here?

I have recorded a short video showing my experience:

azuread

Does the problem appear if you don't open the MainLayout.razor.cs before adding security? I wonder if it is somehow related.

UPDATE: I tested with MainLayout.razor.cs opened and it still worked.

Let me know if I am doing something different than you in the video.

By the way is there anything suspicious in the log file (you can get it from the Help menu).

I do see this??

[2025-09-22 11:32:06.082] [info] Update for version 1.49.1 is not available (latest version: 1.49.1, downgrade is disallowed).
[2025-09-22 11:37:20.112] [error] Error: System.NullReferenceException: Object reference not set to an instance of an object.
at System.Collections.Generic.Dictionary2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) at System.Collections.Generic.Dictionary2.set_Item(TKey key, TValue value)
at Radzen.Server.AssemblyMetadata.FindComponent(String assemblyName, String typeName)
at Radzen.Server.AssemblyMetadata.IsComponentHidden(String assemblyName, String typeName)
at Radzen.Server.RazorProjectEngineExtensions.FilterDescriptor(TagHelperDescriptor descriptor, Compilation compilation)
at Radzen.Server.RazorProjectEngineExtensions.<>c__DisplayClass0_0.b__0(TagHelperDescriptor descriptor)
at System.Linq.Enumerable.ListWhereIterator1.MoveNext() at System.Linq.Enumerable.DistinctByIterator[TSource,TKey](IEnumerable1 source, Func2 keySelector, IEqualityComparer1 comparer)+MoveNext()
at Radzen.Server.RazorProjectEngineExtensions.SerializeComponentDescriptors(RazorProjectEngine engine, Compilation compilation)
at Radzen.Server.ProjectServer.Toolbox()
at Radzen.Server.SolutionFacade.<>c.b__28_0(ProjectServer server)
at Radzen.Server.SolutionFacade.DispatchWhenReadyToRender[T](String filePath, Func`2 action)
at Radzen.Server.SolutionFacade.Toolbox(String filePath)
at lambda_method414(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.Diagnostics.ExceptionHandlerMiddlewareImpl.g__Awaited|10_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)
[2025-09-22 11:53:07.541] [info] Checking for update
[2025-09-22 11:53:07.692] [info] Update for version 1.49.1 is not available (latest version: 1.49.1, downgrade is disallowed).
[2025-09-23 10:37:48.946] [info] Checking for update
[2025-09-23 10:37:49.152] [info] Update for version 1.49.1 is not available (latest version: 1.49.1, downgrade is disallowed).

I did notice I have a "pages" folder in the root of the project, in addition to under the Components folder, that you do not have in your example? I did not create any of this, but this is what was generated? The "unauthorized.razor" is in the Components/Pages folder, but it's CS files are in the /Pages folder in the project?? Why is this?

I still have the old Radzen installed on my computer. Is the new Studio trying to do some type of compatibility thing when generating the code perhaps?? I don't understand why you and I are performing the exact same steps, with the same version, and getting different generated code??

Is there a cache I need to clear perhaps? Maybe something corrupted? Should I reinstall Radzen Studio?

This definitely shouldn't be there. And the fact that it creates designer.razor.cs files definitely means it thinks it is in old Radzen compatibility mode. This happens if it finds a meta directory around the app's folder. Do you have a meta directory somewhere close? Try searching for a meta directory.

I do have many other Radzen projects that are older, but the new ones I created do not have any META folder in the project folder??

These tests are in brand new folders, and they look like this:

C:\dev\test\ssoTest2
├───bin
│ └───Debug
│ └───net8.0
│ └───runtimes
│ ├───unix
│ │ └───lib
│ │ └───netcoreapp3.0
│ └───win
│ └───lib
│ ├───netcoreapp3.0
│ └───netstandard2.0
├───Components
│ ├───Layout
│ └───Pages
├───Controllers
├───Models
├───obj
│ └───Debug
│ └───net8.0
│ ├───ref
│ ├───refint
│ └───staticwebassets
├───Pages
├───Properties
├───Services
└───wwwroot
├───css
└───images

Given these are brand new folders, I"m not sure why Studio would go into compatibility mode, as there was just an empty folder to begin with? Now, if you go up a level or two, there's lots of old Radzen projects that probably have meta stuff. But it shouldn't be looking up there?

Radzen Blazor Studio would look one folder up the .sln file. So if you have a meta directory in c:\dev\test things would go wrong.

But that's not in the project folder? Why is it looking above the SLN file?? I would not have a META folder there tho....it would be down inside yet another project folder??

Well, turns out I had a folder named "meta" as a project folder, on the same root as my test project. It had a app.json file and "layouts" folder in it. It was just a leftover project I guess that happened to be named "meta".

I deleted it, and now the code is being generated!!

So I assume if you create a "meta" folder on the same level as your test project folder, we can reproduce my problem?

My folder was:

c:\dev\test\meta
c:\dev\test\ssoTest2

Does radzen look for actual meta related files, or just the folder name??

We would reproduce the problem but I am not sure if we can anything do to fix it. Such an app would look as an app created by old Radzen while it isn't.

Applications created by old Radzen had the following structure:

\app-dir
   - meta
   - server
        - app.csproj
   - app.sln

The code in Radzen Blazor Studio checks for the presence of a meta directory one level up every csproj file that is in the opened solution.

As you see the meta directory is one level up the app.csproj file (in apps created by old Radzen).

A server app created in Radzen Blazor Studio has the following structure:

\app-dir
   -  app.sln
   -  app.csproj

This is why when you have a case like this:

 - meta
 - app-dir
    - app.csproj

Radzen Blazor Studio would still consider the app as one created by old Radzen.

My old Radzen apps have this structure:

02/15/2021 04:29 PM .
02/15/2021 04:29 PM ..
08/18/2022 10:50 AM 491 .env
02/15/2021 04:13 PM 0 .gitignore
08/18/2022 10:50 AM meta
02/15/2021 04:13 PM 2,722 RadzenTest1.sln
08/18/2022 10:50 AM server

The "meta" folder is inside the project folder, and at the same level as the SLN file?? All of them are like this, I checked? I consider the "project folder" to be the one that holds the SLN file....

Directory of C:\dev\test\radzen-examples\BlazorRest
03/03/2021 02:33 PM meta
0 File(s) 0 bytes

Directory of C:\dev\test\radzen-examples\BlazorTreeDemos
03/03/2021 02:33 PM meta
0 File(s) 0 bytes

Directory of C:\dev\test\radzen-examples\CopyFileDeploy
03/03/2021 02:33 PM meta
0 File(s) 0 bytes

Directory of C:\dev\test\radzen-examples\CRMDemo
03/03/2021 02:33 PM meta
0 File(s) 0 bytes

Directory of C:\dev\test\radzen-examples\CRMDemoBlazor
02/28/2022 05:31 PM meta
0 File(s) 0 bytes

That's why I was confused that it went up yet another folder. But I see now that the old radzen had a project folder called "server" where the files were, and the new Radzen has all the files right under the main folder, and there is no server subfolder. I now understand!!

So the warning here would be do not create any new Radzen project folders in a folder that happens to contain a folder named "meta"!!!

It is not only the meta folder - Radzen Blazor Studio also checks for the presence of an app.json file in it. But yes - not a good idea to create a Radzen app within another Radzen app.