开发者

The report definition for report ' ' has not been specified

i am developing web application, in my app i have to print rdlc without preview.my code is following

    LocalReport report = new LocalReport();
    report.ReportEmbeddedResource = "TCESS.ESales.CommonLayer.Reports.HandlingBillReport.rdlc";
    report.ReportPath="TCESS.ESales.CommonLayer.Reports.HandlingBillReport.rdlc";

    SettlementOfAccountsDTO objSettlementOfAccountsDTO = ESalesUnityContainer.Container.Resolve<ISettlementOfAccountsService>().GetSettlementOfAccountsByAccId(32);
    if (objSettlementOfAccountsDTO.Account_Id > 0)
    {
        SetReportParametersForBill(objSettlementOfAccountsDTO, AccountReportViewer, report);
    }

    Export(report);
    m_currentPageIndex = 0;
    Print();


private Stream CreateStream(string name, string fileNameExtension, Encoding encoding,
                        string mimeType, bool willSeek)
{
    Stream stream = new FileStream(name + "." + fileNameExtension, FileMode.Create);
    m_streams.Add(stream);
    return stream;
}

private void Export(LocalReport report)
{
    string deviceInfo =
      "<DeviceInfo>" +
      "  <OutputFormat>EMF</OutputFormat>" +
      "  <PageWidth>8.5in</PageWidth>" +
      "  <PageHeight>11in</PageHeight>" +
      "  <MarginTop>0.25in</MarginTop>" +
      "  <MarginLeft>0.25in</MarginLeft>" +
      "  <MarginRight>0.25in</MarginRight>" +
      "  <MarginBottom>0.25in</MarginBottom>" +
      "</DeviceInfo>";
    Warning[] warnings;
    m_streams = new List<Stream>();

    report.Render("Image", deviceInfo, CreateStream, out warnings);

    foreach (Stream stream in m_streams)
        stream.Position = 0;
}

private void PrintPage(object sender, PrintPageEventArgs ev)
{
    Metafile pageImage = new Metafile(m_streams[m_currentPageIndex]);

    ev.Graphics.DrawImage(pageImage, 0, 0);

    m_currentPageIndex++;
    ev.HasMorePages = (m_currentPageIndex < m_streams.Count);
}

private void Print()
{
    const string printerName = "\\\\193.168.0.20\\Printer_Q3";

    if (m_streams == null || 开发者_运维技巧m_streams.Count == 0)
        return;

    PrintDocument printDoc = new PrintDocument();
    printDoc.PrinterSettings.PrinterName = printerName;
    if (!printDoc.PrinterSettings.IsValid)
    {
        string msg = String.Format("Can't find printer \"{0}\".", printerName);
        Console.WriteLine(msg);
        return;
    }

    int i=0;
    foreach (Stream stream in m_streams)
    {
        Metafile pageImage = new Metafile(stream);
        pageImage.Save(Server.MapPath("~/Images/"+i.ToString()+".jpg"));
        i++;
    }    
    //printDoc.PrintPage += new PrintPageEventHandler(PrintPage);
    //printDoc.Print();
}

i am getting error "The report definition for report ' ' has not been specified" on line

report.Render("Image", deviceInfo, CreateStream, out warnings);


I just ran into this problem while instantiating a report to export and had to set this property like this:

wrvReport.LocalReport.ReportEmbeddedResource = "CommonLayer.Reports.SalesByPrice.rdlc";

The difference I see is the .LocalReport is the sub-property to set the embedded resource.


From MSDN:

An embedded report resource is a report definition that has been stored as a resource in the calling assembly.

If the ReportPath property has been set, the ReportEmbeddedResource property is ignored.

Therefore, setting the EmbeddedResource property is effectively doing nothing and your ReportPath is also failing because it expects a physical file system path.


I had the same problem. I solved it by setting "Copy to Output Directory = Copy if newer". Cheers.


I also had the same problem, that means that your code is not finding the rdlc file, you need to either use report.ReportEmbeddedResource or report.ReportPath. Looking at your code seems to me that you only need to use report.ReportEmbeddedResource, the other option is for a rdlc that is located in a specific location in your pc or in a network file system

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜