title: ExportToHttpResponse gives : "Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack."
body: <p>On load of ASP.Net page, a report function is called. </p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      GlobalFunctions obj = new GlobalFunctions();
      obj.GetReport(Page PageName, string ReportName);
  }
  </code></pre>
  
  <p>GetReport is defined as : </p>
  
  <pre><code>public void GetReport(Page PageName, string ReportName)
  {
      ReportClass rpt = new ReportClass();
      rpt = GetReportFromDLL(ReportName);   //No error here
      rpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, ReportName); 
  }
  </code></pre>
  
  <p>Error : </p>
  
  <blockquote>
    <p>"Response" is not accessible through the Class.</p>
  </blockquote>
  
  <p>I have tried using "HttpContext.Current.Response" in place of "Response"</p>
  
  <pre><code>rpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat,HttpContext.Current.Response, true, ReportName);
  </code></pre>
  
  <p>But I get this error:</p>
  
  <blockquote>
    <p>"Unable to evaluate expression because the code is optimized or a
    native frame is on top of the call stack."</p>
  </blockquote>
  
  <p>Please help!</p>