简体   繁体   English

零星的“程序集类型中的方法'get_Session'没有实现”

[英]Sporadic “Method 'get_Session' in type from assembly does not have an implementation”

Suddenly the web app that I develop started to give this error message - to the user, but not to me, and only sometimes. 突然,我开发的Web应用程序开始向用户(而不是我)发出此错误消息,并且有时是。

I know that this error can be caused by interface assembly and implementation assembly reference versions mismatch. 我知道此错误可能是由接口程序集和实现程序集引用版本不匹配引起的。 But I did not update Sharp's version for a long time (still use very old one for this project). 但是我已经很长时间没有更新Sharp的版本了(这个项目仍然使用非常旧的版本)。 Also, the error does not happen always, if it was wrong assemblies I suppose it would always fail. 同样,错误并非总是会发生,如果我认为是错误的程序集,它将始终会失败。

What can be the reason? 可能是什么原因? Are there any tracing/loggin tools in framework to find out? 框架中是否有任何跟踪/登录工具可以查找?

Method 'get_Session' in type 'Orders.Data.SafeSessionStorage' 
from assembly 'Orders.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' 
does not have an implementation." 

System.TypeLoadException: Method 'get_Session' in type 'Orders.Data.SafeSessionStorage' from assembly 'Orders.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
   at Orders.Web.MvcApplication.InitializeNHibernateSession()
   at Orders.Web.MvcApplication.<Application_BeginRequest>b__1d()
   at SharpArch.Data.NHibernate.NHibernateInitializer.InitializeNHibernateOnce(Action initMethod)
   at Orders.Web.MvcApplication.Application_BeginRequest(Object sender, EventArgs e)
   at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Here's the SafeSessionStorage. 这是SafeSessionStorage。 It is a slightly modified version of SharpArch's one, to support running in background threads. 它是SharpArch的版本的略微修改版本,以支持在后台线程中运行。

public class SafeSessionStorage : ISessionStorage
{
  [ThreadStatic]
  private static ISession _session;

  public ISession Session
  {
     get
     {
        HttpContext context = HttpContext.Current;
        if (context == null)
           return _session;
        else
        {
           ISession session = context.Items[factoryKey] as ISession;
           return session;
        }
     }
     set
     {
        HttpContext context = HttpContext.Current;
        if (context == null)
           _session = value;
        else
           context.Items[factoryKey] = value;
     }
  }

  public string FactoryKey
  {
     get { return factoryKey; }
  }

  public static void End()
  {
     if (_session != null)
        _session.Close();
     _session = null;
  }

  public void EndRequest()
  {
     ISession session = Session;

     if (session != null)
     {
        session.Close();
        HttpContext context = HttpContext.Current;
        if (context != null)
           context.Items.Remove(factoryKey);
        else
           _session = null;
     }
  }

  private string factoryKey = NHibernateSession.DefaultFactoryKey;
}

Here's where error happens: 这是发生错误的地方:

  private void InitializeNHibernateSession()
  {
     NHibernateInitHelper.InitSession(safeSessionStorage,
        Server.MapPath("~/NHibernate.config"),
        Server.MapPath("~/bin/Orders.Data.dll"));
  }

Here InitSession expects ISessionStorage and is passed SafeSessionStorage, so I suppose that's where type checking fails. 在这里,InitSession需要ISessionStorage并通过SafeSessionStorage传递,所以我想这就是类型检查失败的地方。 And I would suspect assemblies versions but, as I said, it always works for me and sometimes works for the user. 我会怀疑程序集的版本,但正如我所说,它始终对我有用,有时对用户有用。

I would better accept sehe's comment as answer, but anyway. 我最好接受sehe的评论作为答案,但是无论如何。 The problem was a StackOverflowException because of recursive DB data. 问题是由于递归数据库数据而引起的StackOverflowException。 To debug this I had to add logging to many lines inside the suspected code (the error happened on SOAP service acccess and mapping data using DB), and then analyze. 为了调试此问题,我必须在可疑代码内的许多行中添加日志记录(该错误发生在SOAP服务访问和使用DB映射数据上),然后进行分析。 Another approach was to deploy debug build (this is dev server) and use WinDbg, which gave correct exception code 0xe053534f so that I could concentrate on code that may cause this (recursive LINQ method to collect related products). 另一种方法是部署调试版本(这是开发服务器)并使用WinDbg,它提供了正确的异常代码0xe053534f,以便我可以专注于可能导致此问题的代码(递归LINQ方法来收集相关产品)。

The low drive space was a side effect of DW20.exe (dr. watson) eating 1.5 GB space (and CPU). 驱动器空间不足是DW20.exe(Dr。Watson)吃掉1.5 GB空间(和CPU)的副作用。

Event viewer was a little help because it showed the too generic "kernel32.dll, address 0x0000bee7" error that could be stack overflow and could be anything else. 事件查看器有一点帮助,因为它显示了过于笼统的“ kernel32.dll,地址0x0000bee7”错误,该错误可能是堆栈溢出,也可能是其他任何错误。

Getting "method does not have implementation" is the last information I'd expect from such conditions. 我希望从这种情况下获得的最后信息是获取“方法没有实现”。

暂无
暂无

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

相关问题 为什么会收到虚假的TypeLoadException“方法 <foo> 在类型上 <bar> 从组装 <baz> 没有实现”? - Why do I get a spurious TypeLoadException “Method <foo> in type <bar> from assembly <baz> does not have an implementation”? 来自程序集&#39;Unity.Container&#39;的类型&#39;Unity.UnityContainer&#39;中的方法&#39;IsRegistered&#39;,没有实现。? - Method 'IsRegistered' in type 'Unity.UnityContainer' from assembly 'Unity.Container, does not have an implementation.? 程序集“ myAssembly”中类型为“ MyNamespace.MyType”的System.TypeLoadException方法“ GetX”没有实现 - System.TypeLoadException Method 'GetX' in type 'MyNamespace.MyType' from assembly 'myAssembly' does not have an implementation Azure Function 无法启动并显示错误“来自程序集 z 的类型 y 中的方法 x 没有实现”。 - Azure Function fails to start with error "Method x in type y from assembly z does not have an implementation." 程序集“ AutoMapper.Data,版本= 1.0.0.0”中类型为“ AutoMapper.Data.DataReaderMapper”的方法“ IsMatch”没有实现。” - Method 'IsMatch' in type 'AutoMapper.Data.DataReaderMapper' from assembly 'AutoMapper.Data, Version=1.0.0.0 does not have an implementation." 类型&#39;ServiceStack.JsonServiceClient&#39;中的方法&#39;Get&#39;…没有实现 - Method 'Get' in type 'ServiceStack.JsonServiceClient' … does not have an implementation 类型中的方法“get_Properties”没有实现 - Method 'get_Properties' in type does not have an implementation Assembly.GetExportedTypes抛出异常方法没有实现 - Assembly.GetExportedTypes throws exception method does not have an implementation 程序集“Ninject.Extensions.Interception.DynamicProxy”中的方法没有实现 - Method from assembly 'Ninject.Extensions.Interception.DynamicProxy' does not have an implementation Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure.Internal.NpgsqlOptionsExtension 类型中的方法“get_Info”没有实现 - Method 'get_Info' in type Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure.Internal.NpgsqlOptionsExtension does not have an implementation
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM