【问题标题】:Sporadic "Method 'get_Session' in type from assembly does not have an implementation"零星的“来自程序集的类型中的方法 'get_Session' 没有实现”
【发布时间】:2011-08-24 17:57:30
【问题描述】:

突然间,我开发的网络应用程序开始向用户提供此错误消息,但对我没有,而且只是有时。

我知道这个错误可能是由接口汇编和实现汇编参考版本不匹配引起的。但是我很长时间没有更新夏普的版本(这个项目仍然使用很旧的版本)。此外,错误并不总是发生,如果是错误的程序集,我想它总是会失败。

可能是什么原因?框架中是否有任何跟踪/登录工具可供查找?

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)

这里是 SafeSessionStorage。它是 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;
}

这是发生错误的地方:

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

这里 InitSession 需要 ISessionStorage 并通过 SafeSessionStorage,所以我想这就是类型检查失败的地方。我会怀疑程序集版本,但正如我所说,它总是对我有用,有时也对用户有用。

【问题讨论】:

  • DLL 文件是否有时无法访问?我可以想象这种 'catastrophic failure (OT)' 会导致 Web 应用程序重新加载。如果DLL文件同时被重写/解锁,则说明错误只弹出一次
  • 嗯,对,我在 w3wp 的事件查看器中看到了错误,在 kernel32.dll 中,地址为 0x0000bee7。
  • 我想一个未处理的异常正在卸载您的 appdomain。谷歌搜索(例如here 或检查资源泄漏
  • 实际上服务器有 1MB 可用空间。
  • @Queen:感谢您的反馈。你可以把它作为一个答案,这样人们就可以看到它已经解决了。关于主题:我想这是 JIT 未能为编译后的图像分配空间

标签: c# .net asp.net-mvc sharp-architecture typeloadexception


【解决方案1】:

我最好接受 sehe 的评论作为答案,但无论如何。由于递归数据库数据,问题是 StackOverflowException。为了调试它,我必须在可疑代码中的许多行中添加日志记录(错误发生在 SOAP 服务访问和使用 DB 映射数据上),然后进行分析。另一种方法是部署调试版本(这是开发服务器)并使用 WinDbg,它给出了正确的异常代码 0xe053534f,这样我就可以专注于可能导致这种情况的代码(递归 LINQ 方法来收集相关产品)。

驱动器空间不足是 DW20.exe (dr. watson) 占用 1.5 GB 空间(和 CPU)的副作用。

事件查看器有点帮助,因为它显示了过于通用的“kernel32.dll,地址 0x0000bee7”错误,可能是堆栈溢出,也可能是其他任何错误。

得到“方法没有实现”是我在这种情况下所期望的最后信息。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-07-17
    • 1970-01-01
    • 1970-01-01
    • 2012-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多