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

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发生了变化。

 

源代码需要请与我联系!

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值