NetPad icon indicating copy to clipboard operation
NetPad copied to clipboard

MiniProfiler Broken in Version 9

Open dstinit opened this issue 5 months ago • 4 comments

I have another script (setting up MiniProfiler in a local ASP.NET instance) that works with version 8, but is broken since 9. Here is a minimal repro:

5296d649-f84b-4a85-8fb7-2aa5cbcd2bd1
{"config":{"kind":"Program","targetFrameworkVersion":"DotNet8","optimizationLevel":"Debug","useAspNet":true,"namespaces":["System","System.Collections","System.Collections.Generic","System.Data","System.Diagnostics","System.IO","System.Linq","System.Linq.Expressions","System.Net.Http","System.Reflection","System.Text","System.Text.RegularExpressions","System.Threading","System.Threading.Tasks","System.Xml","System.Xml.Linq","System.Xml.XPath"],"references":[{"discriminator":"PackageReference","packageId":"MiniProfiler.AspNetCore.Mvc","version":"4.5.4","title":"MiniProfiler for ASP.NET Core MVC"}]},"dataConnection":null}
#Code
var builder = WebApplication.CreateBuilder();

builder.Services.AddMiniProfiler();

Error:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.TypeLoadException: Method 'get_Services' in type 'StackExchange.Profiling.Internal.MiniProfilerBuilder' from assembly 'MiniProfiler.AspNetCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b44f9351044011a3' does not have an implementation.
   at Microsoft.Extensions.DependencyInjection.MvcExtensions.AddMiniProfiler(IServiceCollection services, Action`1 configureOptions)
   at Program.<Main>$(String[] args) in :line3
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
   --- End of inner exception stack trace ---
   at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
   at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at NetPad.Apps.ScriptHost.ScriptRunner.Execute(String scriptAssemblyPath, String[] probingPaths) in /Users/runner/work/NetPad/NetPad/src/Apps/NetPad.Apps.ScriptHost/ScriptRunner.cs:line 113
   at NetPad.Apps.ScriptHost.ScriptRunner.Run(RunScriptMessage message) in /Users/runner/work/NetPad/NetPad/src/Apps/NetPad.Apps.ScriptHost/ScriptRunner.cs:line 70

dstinit avatar Jul 19 '25 16:07 dstinit

Thank you for the report. I'll take a look.

tareqimbasher avatar Jul 20 '25 20:07 tareqimbasher

To give an update, still broken with 0.10, but it does work with npad cli.

dstinit avatar Oct 30 '25 16:10 dstinit

Thank you for the update. I was planning on getting a fix out for this (and #340) in v0.10 but I wasn't able to get it out in time. The issue is one of the packages in the dependency graph of MiniProfiler.AspNetCore.Mvc or ScottPlot (can't remember which one) is delisted on NuGet.org and NetPad isn't able to resolve which version of that dependency to use instead. I will revisit this soon and get it resolved.

I appreciate the feedback on it working on npad cli. That helps. The CLI uses the same script execution model that NetPad used in v0.8. Starting in v0.9 NetPad (GUI) uses a new execution model, which is when you reported the 2 issues, so seems like a regression. Also any feedback on the cli would be great, the things you don't like especially. I haven't announced it yet, I was planning to with the next release but I'm glad you found it!

tareqimbasher avatar Oct 30 '25 18:10 tareqimbasher

I closed issue #340 to consolidate here

tareqimbasher avatar Oct 30 '25 18:10 tareqimbasher

Sorry this has been open for quite a while. I will get this fixed soon.

tareqimbasher avatar Dec 01 '25 17:12 tareqimbasher