aspnetcore icon indicating copy to clipboard operation
aspnetcore copied to clipboard

Misleading error when DI fails

Open vsfeedback opened this issue 1 year ago • 3 comments

This issue has been moved from a ticket on Developer Community.


[severity:It's more difficult to complete my work] I recently lost over an hour to this one. I accidentally used:

@inject Logger<MyComponent>

instead of

@inject ILogger<MyCompnent>

The error it was giving me came from ExecutionContext stating there was a null value in a callback and crashed the entire application. No where in the stack trace did it say where the error was, only that it was coming from SignalR (which is also misleading). This is actually a pretty generic error that you get when any number of things go wrong with a razor page.

In this particular case, I expected to get a typical error stating a dependency could not be resolved. Literally nothing useful was in the stack trace, I had to start putting break points in the .NET Framework source code to finally see something that let me to see that the problem was related to DI caused by a single character typo. Hours lost. I'm sure it is well known that tool support for Razor components is lacking - errors and/unhelpful are quite misleading when they come from a razor component.


Original Comments

Feedback Bot on 8/21/2024, 07:30 PM:

(private comment, text removed)


Original Solutions

(no solutions)

vsfeedback avatar Aug 23 '24 17:08 vsfeedback

Thank you for filing this issue. In order for us to investigate this issue, please provide a minimal repro project that illustrates the problem without unnecessary code. Please share with us in a public GitHub repo because we cannot open ZIP attachments, and don't include any confidential content.

The error it was giving me came from ExecutionContext stating there was a null value in a callback and crashed the entire application.

Can you please provide a repro app demonstrating this happening due to a missing dependency?

halter73 avatar Aug 23 '24 17:08 halter73

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

See our Issue Management Policies for more information.