我已经在本网站上引用了一些文章,使用控制台应用程序将 .rdlc 渲染为 .pdf 输出。我是 C# .net 的新手,构建了一个与以下相同的应用程序,给出错误消息:>Rdclrender.exe!Rdclrender.Program.Main( string[] args = {string[0]}) 第 28 行我的课程如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Reporting.WinForms;
namespace Rdclrender
{
class Program
{
static void Main(string[] args)
{
// Variables
Warning[] warnings;
string[] streamIds;
string mimeType = string.Empty;
string encoding = string.Empty;
string extension = string.Empty;
// Setup the report viewer object and get the array of bytes
ReportViewer viewer = new ReportViewer();
viewer.ProcessingMode = ProcessingMode.Local;
viewer.LocalReport.ReportPath = "Report.rdlc";
byte[] bytes = viewer.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamIds, out warnings);
using (System.IO.FileStream fs = new System.IO.FileStream("output.pdf", System.IO.FileMode.Create))
{
fs.Write(bytes, 0, bytes.Length);
}
// Now that you have all the bytes representing the PDF report, buffer it and send it to the client.
/* Response.Buffer = true;
Response.Clear();
Response.ContentType = mimeType;
Response.AddHeader("content-disposition", "attachment; filename=" + fileName + "." + extension);
Response.BinaryWrite(bytes); // create the file
Response.Flush(); // send it to the client to download*/
}
}
}
这是从 .rdl 创建 pdf 的方法吗?我已手动将我的 .rdl 重命名为 .rdlc ,并将 .rdlc 项目添加到项目中。