繁体   English   中英

带有Miniprofiler.Windows的System.MissingMethodException

[英]System.MissingMethodException with Miniprofiler.Windows

最近在我WinForm项目,我安装MiniProfiler.Windows和写入以下装饰我的QueryHandler秒(我使用CQRS ):

public class MiniProfilerQueryHandlerDecorator<TQuery,TResult>:IQueryHandler<TQuery,TResult> where TQuery : IQueryParameter<TResult>
{
    private readonly IQueryHandler<TQuery, TResult> _decoratee;

    public MiniProfilerQueryHandlerDecorator(IQueryHandler<TQuery, TResult> decoratee)
    {
        _decoratee = decoratee;
    }

    public TResult Handle(TQuery request)
    {
        TResult result;
        using (StackExchange.Profiling.MiniProfiler.Current.Step("Call QueryHandler"))
        {
            result =_decoratee.Handle(request); //call some Linq to entity queries
        }
        var friendlyString = ConsoleProfiling.StopAndGetConsoleFriendlyOutputStringWithSqlTimings();
        Debug.WriteLine(friendlyString);
        return result;
    }
}

我在var friendlyString=ConsoleProfiling.StopAndGetConsoleFriendlyOutputStringWithSqlTimings()行中收到以下错误。

IASCo.Application.Core.dll中发生了类型为'System.MissingMethodException'的未处理异常

附加信息:找不到方法:“ Boolean StackExchange.Profiling.MiniProfiler.get_HasSqlTimings()”。

有人知道问题出在哪里吗?

MissingMethodException =试图动态访问程序集的删除或重命名方法,而该程序集的强名( msdn )没有引用该方法。

或如以下答案所示

当仍然有旧版本的DLL徘徊时,可能会出现此问题

我注意到MiniProfiler.Windows库使用的是非常旧(超过2年)的MiniProfiler版本。 该版本的代码确实确实具有MiniProfiler.HasSqlTimings属性。 但是,当前版本(3.0.11)不再具有此属性。

我猜想您正在使用上面链接的MiniProfiler.Windows库中的代码,但不是使用v3 MiniProfiler dll(可能是从nuget下载),而是使用了它们保存在/ packages中的v2 MiniProfiler dll。 这将解释您得到的异常。

如果确实如此,则可以通过下载2.0.2 nuget版本( Install-Package MiniProfiler -Version 2.0.2 )或通过升级ConsoleProfiling的代码以与ConsoleProfiling v3兼容来解决此问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM