question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MiniProfiler, .NET 5, & ProfilingViewComponentInvokerFactory

See original GitHub issue

I’m not sure if I’m crazy, or what the deal is here. Does MiniProfiler support AspNetCore on NET5? I don’t see a pre-release version and I’m getting some weird behaviors where it doesn’t seem like it’s loading the correct dll.

I was curious to lookup profiling for ViewComponents in MiniProfiler and stumbled across #286. Which seems to be exactly what I was looking for, but it doesn’t seem to be working. I tried to wire it up myself via a call to

services.AddSingleton<Microsoft.AspNetCore.Mvc.ViewComponents.IViewComponentInvokerFactory, 
StackExchange.Profiling.Internal.ProfilingViewComponentInvokerFactory>();

But I get an error on being unable to resolve ProfilingViewComponentInvokerFactory. I tried navigating to the source of AddMiniProfiler and got redirected to the decompiled source for \.nuget\packages\miniprofiler.aspnetcore.mvc\4.2.22\lib\netcoreapp3.0\MiniProfiler.AspNetCore.Mvc.dll. Which seemed odd, cause I’m not on netcoreapp3.0, I’m on net5, but so be it. I checked the source in github MiniProfiler.AspNetCore.Mvc/MvcExtensions.cs, and even that matches what my decompiled source gives, if NETCOREAPP3_0 resolved to true. However if I actually use #if NETCOREAPP3_0 in my own code, it’s greyed out and doesn’t run.

Is there a compatibility issue with the MiniProfiler Nuget package, and NET5? And if not, how do you get support for ViewComponent profiling (and out of curiosity, shouldn’t ProfilingViewComponentInvokerFactory be registered as a singleton like DefaultViewComponentInvokerFactory is by default?)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
nickalbrechtcommented, Nov 9, 2021

Awesome! Glad to see that this is something that can be tracked. I remember coming across the calls to BeforeViewComponent in the component invoker, but didn’t have experience/understanding with diagnostic listeners to understand how they were used, or that MiniProfiler used them underneath. Super slick, I’ll have to read up on how they work. Excited to see this added to MiniProfiler. Always appreciate your time on this stuff!

No worries, and congrats on the job! I’m not at all surprised to see Microsoft eventually snag you up with your skills and talents. Looking forward to seeing what sort of stuff you end up working on, both with regards to Azure and other OSS contributions!

0reactions
nickalbrechtcommented, Nov 11, 2021

Just grabbed 4.2.49 off of MyGet to give it a shot, and it seems to work great for me. Components show in the list of events exactly where I’d expect. Any ideas as to when the next publish to Nuget is planned?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Record ViewComponents as steps for aspnet core. #286
Hi! I have been playing with MiniProfiler.AspNetCore and .Net Core 3.0 just for fun and I saw this commit aspnet/Mvc@5a6d438#diff- ...
Read more >
MiniProfiler for .NET (including ASP.NET & ASP.NET Core)
MiniProfiler for .NET now has a few flavors since .NET Core differs quite a bit from .NET Full Framework on the ASP.NET front....
Read more >
MiniProfiler: A simple but effective mini-profiler for .NET and ...
An ADO.NET profiler, capable of profiling calls on raw ADO.NET (SQL Server, Oracle, etc), LINQ-to-SQL, Entity Framework (including Code First and EF Core),...
Read more >
ASP.NET
The ASP.NET MVC 5 sample is here, with the important bits in Global.asax.cs. Installation and Configuration. Install the NuGet Package: MiniProfiler.Mvc5.
Read more >
ASP.NET Core
The ASP.NET Core sample is here, with the important bits in Startup.cs. Installation and Configuration. Install the NuGet Package: MiniProfiler.AspNetCore.Mvc.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found