2012-05-01 11 views
0

rdlcレポートの結果をファイルに書き込むMVCコントローラメソッドがあります。これはローカルマシンで正常に動作しますが、実稼働環境にパブリッシュされると、setparameters行での実行が停止し、例外がトリガーされません。すべての手がかりをいただければ幸いです。LocalReport.SetParametersで実行を停止してもエラーが発生しないで呼び出される理由

public JsonResult GenerateSignInSheet(string id) 
    { 
     try 
     { 
      string pgmid = id; 
      string strProgDate = ""; 
      DateTime? dtProgDate = null; 
      Program prog = db.Programs.SingleOrDefault(p => p.ProgramID == pgmid); 
      if (prog != null) 
       dtProgDate = prog.ProgDate; 
      if (dtProgDate != null) 
       strProgDate = String.Format("{0:d}", dtProgDate); 

      string strProgLoc = string.Empty; 
      var locInfo = this.dc.usp_ProgramLocSiteInfo(id).SingleOrDefault(); 
      if (locInfo != null) strProgLoc = locInfo.VendorOrHost ?? string.Empty; 

      //Rep information 
      string strRepName = string.Empty; 

      LocalReport localReport = new LocalReport(); 

      // the following 2 lines will allow globals to work - MS gotcha 
      System.Security.PermissionSet sec = new System.Security.PermissionSet(System.Security.Permissions.PermissionState.Unrestricted); 
      localReport.SetBasePermissionsForSandboxAppDomain(sec); 

      localReport.ReportPath = Server.MapPath("~/Content/Reports/RptSignInSheetPrefilled.rdlc"); 
      var sourceList = dc.GetRSVPListForSignin(pgmid).ToList(); 
      ReportDataSource reportDataSource = new ReportDataSource("DataSetRSVPList", sourceList); 
      ReportParameter p1 = new ReportParameter("ProgramID", pgmid); 
      ReportParameter p2 = new ReportParameter("ProgDate", strProgDate); 
      ReportParameter p3 = new ReportParameter("LocName", strProgLoc); 
      ReportParameter p4 = new ReportParameter("RepName", strRepName); 

      localReport.SetParameters(new ReportParameterCollection { p1, p2, p3, p4 }); 
      localReport.DataSources.Add(reportDataSource); 

      //string reportType = "PDF"; 
      string mimeType; 
      string encoding; 
      string fileNameExtension; 

      //The DeviceInfo settings should be changed based on the reportType 
      //http://msdn2.microsoft.com/en-us/library/ms155397.aspx 

      string deviceInfo = 

      "<DeviceInfo>" + 
      " <OutputFormat>PDF</OutputFormat>" + 
      " <PageWidth>11in</PageWidth>" + 
      " <PageHeight>8.5in</PageHeight>" + 
      " <MarginTop>0.5in</MarginTop>" + 
      " <MarginLeft>0.5in</MarginLeft>" + 
      " <MarginRight>0.5in</MarginRight>" + 
      " <MarginBottom>0.5in</MarginBottom>" + 
      "</DeviceInfo>"; 

      Warning[] warnings; 
      string[] streams; 
      byte[] renderedBytes; 

      //Render the report 
      renderedBytes = localReport.Render(
       "PDF", 
       deviceInfo, 
       out mimeType, 
       out encoding, 
       out fileNameExtension, 
       out streams, 
       out warnings); 

      string strPDFOutputPath = System.Configuration.ConfigurationManager.AppSettings["PDFDocumentsPath"].ToString(); 
      string strPDFFilename = strPDFOutputPath + id.Replace("-", string.Empty) + ".pdf"; 

      System.IO.FileStream fs = new System.IO.FileStream(strPDFFilename, System.IO.FileMode.Create); 
      fs.Write(renderedBytes, 0, renderedBytes.Length); 
      fs.Close(); 
      fs.Dispose(); 


      //var theFile = File(renderedBytes, mimeType); 

      return Json(new { File = strPDFFilename }); 

     } 
     catch (Exception ex) 
     { 
      Elmah.ErrorSignal.FromCurrentContext().Raise(ex); 
      return Json(new { File = "" }); 
     } 
    } 

答えて

0

dllのバージョンを確認する必要があります。

Iいたのと同じ問題が、私私の場合(Asp.Net 4レイザー、MVC)必要とされるもののバージョン11:

  • Microsoft.ReportViewer.Common
  • Microsoft.ReportViewer.ProcessingObjects
  • マイクロソフト.ReportViewer.WebForms
関連する問題