您的位置:首页 > 其它

关于webbupload在IIS7.0下出现未将对象引用到实例的错误解决方案

2009-08-05 13:34 253 查看
1.错误内容

“/”应用程序中的服务器错误。

未将对象引用设置到对象的实例。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。

源错误:

执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。

堆栈跟踪:

[NullReferenceException: 未将对象引用设置到对象的实例。]
Rsoft.BigFileUpload.WebbHttpModule.WebbUpload_BeginRequest(Object sender, EventArgs e) +1603
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +68
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
版本信息: Microsoft .NET Framework 版本:2.0.50727.4016; ASP.NET 版本:2.0.50727.4016

2.错误产生的位置

组件源文件:WebbUploadModule.cs

函数:AddTextPartToRequest

修改为:

private byte[] AddTextPartToRequest(HttpWorkerRequest m_request, byte[] m_textData)
{
Type m_type;
BindingFlags m_flags =(BindingFlags.NonPublic | BindingFlags.Instance);
//Is there application host IIS6.0?
if (HttpContext.Current.Request.ServerVariables["SERVER_SOFTWARE"].Equals("Microsoft-IIS/6.0"))
{
m_type = m_request.GetType().BaseType.BaseType;
}
else if (HttpContext.Current.Request.ServerVariables["SERVER_SOFTWARE"].Equals("Microsoft-IIS/7.0"))
{
m_type = m_request.GetType().BaseType.BaseType.BaseType;
}
else
{
m_type = m_request.GetType().BaseType;
}
//Set values of working request
m_type.GetField("_contentAvailLength", m_flags).SetValue(m_request, m_textData.Length);
m_type.GetField("_contentTotalLength", m_flags).SetValue(m_request, m_textData.Length);
m_type.GetField("_preloadedContent", m_flags).SetValue(m_request, m_textData);
m_type.GetField("_preloadedContentRead", m_flags).SetValue(m_request, true);
return m_textData;
}

3.原因分析:IIS7.0下GetType发生了变化。

源代码需要请与我联系!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐