刚刚将一个 Web 项目升级到 .NET 6.0。项目已编译,但当我运行该网站时,出现以下错误:
InvalidOperationException:找不到包“System.Security.Cryptography”的编译库位置。
我正在使用 MiniProfiler.AspNetCore.Mvc 4.2.2。为了调试,我添加了 NuGet System.Security.Cryptography.Pkcs 包,但这并不能解决问题。
有什么解决问题的想法吗?
堆栈显示MiniProfilerMiddleware.cs正在引发异常:
InvalidOperationException: Cannot find compilation library location for package 'System.Security.Cryptography.Pkcs'
Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths(ICompilationAssemblyResolver resolver, List<string> assemblies)
Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths()
Microsoft.AspNetCore.Mvc.ApplicationParts.AssemblyPartExtensions+<>c.<GetReferencePaths>b__0_0(CompilationLibrary library)
System.Linq.Enumerable+SelectManySingleSelectorIterator<TSource, TResult>.MoveNext()
System.Collections.Generic.List<T>.InsertRange(int index, IEnumerable<T> collection)
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.RazorReferenceManager.GetReferencePaths()
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.RazorReferenceManager.GetCompilationReferences()
System.Threading.LazyInitializer.EnsureInitializedCore<T>(ref T target, ref bool initialized, ref object syncLock, Func<T> valueFactory)
System.Threading.LazyInitializer.EnsureInitialized<T>(ref T target, ref bool initialized, ref object syncLock, Func<T> valueFactory)
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.RazorReferenceManager.get_CompilationReferences()
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.LazyMetadataReferenceFeature.get_References()
Microsoft.CodeAnalysis.Razor.CompilationTagHelperFeature.GetDescriptors()
Microsoft.AspNetCore.Razor.Language.DefaultRazorTagHelperBinderPhase.ExecuteCore(RazorCodeDocument codeDocument)
Microsoft.AspNetCore.Razor.Language.RazorEnginePhaseBase.Execute(RazorCodeDocument codeDocument)
Microsoft.AspNetCore.Razor.Language.DefaultRazorEngine.Process(RazorCodeDocument document)
Microsoft.AspNetCore.Razor.Language.DefaultRazorProjectEngine.ProcessCore(RazorCodeDocument codeDocument)
Microsoft.AspNetCore.Razor.Language.RazorProjectEngine.Process(RazorProjectItem projectItem)
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.RuntimeViewCompiler.CompileAndEmit(string relativePath)
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.RuntimeViewCompiler.OnCacheMiss(string normalizedPath)
Microsoft.AspNetCore.Mvc.Razor.Compilation.DefaultRazorPageFactoryProvider.CreateFactory(string …
Run Code Online (Sandbox Code Playgroud) asp.net asp.net-mvc mvc-mini-profiler miniprofiler asp.net-core
我有一个C#webserver,我一直在使用StackOverflow miniprofiler进行分析.因为它不是ASP.NET服务器,但每个请求通常都是在自己的线程上执行的,所以我操纵了miniprofiler使用ThreadStatic
存储来跟踪从开始到结束的传入请求的所有分析器.这很好用.
最近我们已将所有内容转换为使用async/await
,这意味着在await
通常不会返回到相同内容之后继续Thread
,因此ThreadStatic
存储不再有效.
ThreadPool
在这种情况下,在不同线程之间传递一些小数据的最佳方法是什么?是否存在SynchronizationContext
对此类内容有用的现有实现?
最近我试图描述使用AngularJS $ http服务调用的ASP MVC方法,并且我注意到MiniProfiler不像JQuery的AJAX调用那样更新数据.
有没有办法将MiniProfiler与Angular一起使用?
我已将Miniprofiler连接到本地 ASP.NET Core 项目,并且它按预期工作。现在我需要它在托管环境中工作,其中同一网站有多个实例并且没有粘性会话。据我了解,如果您在配置探查器时仅设置存储选项,则应该支持此功能。但是,设置存储似乎没有任何作用。我像这样初始化存储:
var redisConnection = "...";
MiniProfiler.DefaultOptions.Storage = new RedisStorage(redisConnection);
app.UseMiniProfiler();
Run Code Online (Sandbox Code Playgroud)
完成此操作后,我希望可以打开一个分析页面,并将结果添加到我的 redis 缓存中。然后,我还希望我的网站的新实例会列出原始分析结果。但是,在生成新的配置文件结果时,不会将任何内容写入缓存。
为了测试连接,我尝试手动保存探查器实例 ( storage.Save()
),并将其保存到存储中。但同样,在显示探查器结果时,不会加载保存的结果(无论如何,我见过的示例都不需要您这样做)。我有一种感觉,我错过了关于存储应该如何工作的一些要点。
我正在研究(WebForms)Web应用程序的运行时分析工具.
我考虑过MiniProfiler和Glimpse.
在MiniProfiler中,记录分析消息很容易(实际上,唯一的方法吗?):
var profiler = MiniProfiler.Current;
using (profiler.Step("Doing complex stuff"))
{
using (profiler.Step("Step A"))
{ // something more interesting here
Thread.Sleep(100);
}
using (profiler.Step("Step B"))
{ // and here
Thread.Sleep(250);
}
}
Run Code Online (Sandbox Code Playgroud)
在Glimpse中,您可以获得请求生命周期的自动分析 - 但我不确定分析自定义业务逻辑方案的最简单方法是什么.
我在这里读到Glimpse System.Diagnostics.(Trace|Debug).Trace*()
在其"Trace"选项卡中支持,但这只能及时显示,它似乎不会对嵌套范围进行分析.能够以更结构化的方式跟踪自定义数据会很好 - 例如在"时间轴"选项卡中.
所以问题是,我可以(希望很容易)在Glimpse中获得类似MiniProfiler的结构化自定义日志记录吗?
PS.我知道有一个展示MiniProfiler数据的Glimpse扩展,但看起来它已被抛弃.
PPS.我很高兴看到Glimpse在我的WebForms项目(在IIS经典管道模式中)开箱即用(几乎)!AFAIK,MiniProfiler在配置上不是很好,它偏向于MVC.
我试图MiniProfiler
在我的asp MVC项目中使用堆栈交换,但是在我调用的视图中却收到了一个非常烦人的错误消息
@using StackExchange.Profiling
Run Code Online (Sandbox Code Playgroud)
和
@MiniProfiler.RenderIncludes()
Run Code Online (Sandbox Code Playgroud)
在RenderIncludes
网上,VS抱怨
类型'MiniProfiler'存在于'MiniProfiler.Shared,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b44f9351044011a3'和'MiniProfiler,Version = 3.2.0.157,Culture = neutral,PublicKeyToken = b44f9351044011a3'中
我已经检查了(.csprroj
)项目文件,它仅包含一个引用的元素MiniProfiler
:
<Reference Include="MiniProfiler, Version=3.2.0.157, Culture=neutral, PublicKeyToken=b44f9351044011a3, processorArchitecture=MSIL">
<HintPath>..\packages\MiniProfiler.3.2.0.157\lib\net40\MiniProfiler.dll</HintPath>
</Reference>
Run Code Online (Sandbox Code Playgroud)
我也签到了packages.config
,它也只有1个引用MiniProfiler
:
<package id="MiniProfiler" version="3.2.0.157" targetFramework="net452" />
Run Code Online (Sandbox Code Playgroud)
我清理了项目,然后重新启动Visual Studio,但没有成功。这是怎么回事
我已将以下代码添加到与实体框架配合使用的 asp.net core .net 5 应用程序中。在startup.cs中我有:
services.AddMiniProfiler(options =>
{
options.PopupRenderPosition = StackExchange.Profiling.RenderPosition.BottomLeft;
options.PopupShowTimeWithChildren = true;
options.RouteBasePath = "/profiler";
}).AddEntityFramework();
Run Code Online (Sandbox Code Playgroud)
在我的 app.useRouting 之前我有
app.UseMiniProfiler();
Run Code Online (Sandbox Code Playgroud)
我添加到一个控制器,我知道它被称为以下内容:
using System.Collections.Generic;
using System.Linq;
using EFSvcc.Models;
using Microsoft.AspNetCore.Mvc;
using StackExchange.Profiling;
namespace WebAppReactCRA.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private readonly svcodecampContext _dbContext;
public WeatherForecastController(svcodecampContext dbContext)
{
_dbContext = dbContext;
}
[HttpGet]
public List<DiscountCode> Get()
{
List<DiscountCode> discountCodes;
using (MiniProfiler.Current.Step("WeatherForecastController: Groupby Clause For Total and Sent"))
{
var z = _dbContext.DiscountCodes;
discountCodes = z.ToList(); …
Run Code Online (Sandbox Code Playgroud) mvc-mini-profiler entity-framework-core miniprofiler asp.net-core
我正在使用 MiniProfiler 检查 API 的性能。
我已经使用 MiniProfiler 语句检测了我的 API 代码,并在 API 方法结束时调用MiniProfiler.RenderPlainText();
打印性能日志并将其保存在我的数据库中。
不幸的是,这个打印输出似乎被中间“剪切”了并且不完整。
对于 24M 字符以及 350k 字符的打印输出来说都是如此,因此这似乎不是某种阈值的问题。
您知道如何获取完整日志吗?
另一种(次优)策略可能是配置 MiniProfiler 跳过琐碎的计时(例如 < 0.2 毫秒)并仅打印相关的计时...
请告诉我这个问题是否有解决方案。
谢谢你!
盖尔西
我按照这些说明将 MVC 附加MiniProfiler
到我的项目。
采取的步骤:
Install-Package MiniProfiler.Mvc5 -IncludePrerelease
using StackExchange.Profiling
在Global.asax.cs
MiniProfiler.Start()
在Application_BeginRequest
但 Visual Studio 抱怨说
“MiniProfiler”不包含“Start”的定义
所以我检查了建议的示例文件并尝试模仿它,但结果几乎相同,即
“MiniProfiler”不包含“StartNew”的定义
这里发生了什么?这个文档需要更新吗?
miniprofiler ×10
asp.net-mvc ×4
c# ×4
asp.net-core ×3
asp.net ×2
.net-6.0 ×1
.net-core ×1
angularjs ×1
async-await ×1
glimpse ×1
linq2db ×1
nlog ×1
performance ×1
sql ×1