请查看以下代码行:
export.file = rv.LocalReport.Render(extension, deviceinfo, out mimetype, out encoding,
out extension, out stream, out wrn);
流总是通过导致“参数不能为空”错误而变为空。下面是我的实际代码:
public Export_Info create_export(string procedure, List<SqlParameter> parameter,
int export_type, string rdlc_path = "")
{
Export_Info export = new Export_Info();
ReportViewer rv = new ReportViewer();
ReportViewer rvlabel = new ReportViewer();
string[] stream = null;
Microsoft.Reporting.WebForms.Warning[] wrn;
byte[] result = null;
string mimetype = null;
string encoding;
string extension = ex.get_Export_Value(export_type);
string deviceinfo = null;
DataReturn dr = dtran.GetTransaction(procedure, parameter);
rv.LocalReport.ReportPath = rdlc_path;
rv.LocalReport.DataSources.Clear();
if (dr.Data.Tables.Count >= 1)
{
int tbl = 0;
foreach(DataTable t in dr.Data.Tables)
{
string n = "";
if (tbl == 0)
{
n = "Main";
}
else
{
n = "Main_" + tbl.ToString();
}
rv.LocalReport.DataSources.Add(new ReportDataSource(n, t));
tbl++;
}
}
try
{
export.file = rv.LocalReport.Render(extension, deviceinfo, out mimetype,
out encoding, out extension, out stream, out wrn);
}
catch (Exception err)
{
string filePath = @"C:\Error.txt";
using (StreamWriter writer = new StreamWriter(filePath, true))
{
writer.WriteLine("Message :" + err.Message + "<br/>" + Environment.NewLine +
"StackTrace :" + err.StackTrace + "" + Environment.NewLine +
"Date :" + DateTime.Now.ToString());
writer.WriteLine(Environment.NewLine + "--------------------------------" +
"---------------------------------------------" + Environment.NewLine);
}
}
//export.label = rvlabel.LocalReport.Render(extension, deviceinfo, out mimetype,
// out encoding, out extension, out stream, out wrn);
return export;
}
我的存储过程正在正确返回值。但是,“ Stream”变量仍然为空。对解决这个问题有帮助吗?
更新:在下面添加堆栈跟踪消息:
消息:处理本地报告时发生错误。
StackTrace:在
Microsoft.Reporting.WebForms.LocalReport.InternalRender(字符串格式,布尔型allowInternalRenderers,字符串deviceInfo,PageCountMode pageCountMode,CreateAndRegisterStream createStreamCallback,Warning []和警告)
在Microsoft.Reporting.WebForms.LocalReport.InternalRender(字符串格式,布尔型allowInternalRenderers,字符串deviceInfo,PageCountMode pageCountMode,String&mimeType,String&编码,String&fileNameExtension,String []&流,Warning []&警告)
在Microsoft.Reporting.WebForms.LocalReport.Render(字符串格式,字符串deviceInfo,PageCountMode pageCountMode,字符串和mimeType,字符串和编码,字符串和fileNameExtension,字符串[]和流,警告[]和警告)
在Microsoft.Reporting.WebForms.Report.Render(字符串格式,字符串deviceInfo,字符串和mimeType,字符串和编码,字符串和fileNameExtension,字符串[]&流,警告[]&警告)
在Proj.export(字符串过程,List'1参数,Int32 export_type,字符串rdlc_path)在C:\ Proj \ Controllers \ Export.cs:line 75