【发布时间】: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