C# 报表的报表定义'';尚未指定

C# 报表的报表定义'';尚未指定,c#,asp.net,C#,Asp.net,我正在开发web应用程序,在我的应用程序中,我必须在没有预览的情况下打印rdlc LocalReport report = new LocalReport(); report.ReportEmbeddedResource = "TCESS.ESales.CommonLayer.Reports.HandlingBillReport.rdlc"; report.ReportPath="TCESS.ESales.CommonLayer.Reports.HandlingBillR

我正在开发web应用程序,在我的应用程序中,我必须在没有预览的情况下打印rdlc

    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();
}

我只是在实例化要导出的报表时遇到了这个问题,必须按如下方式设置此属性:

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

我看到的区别是
。LocalReport
是设置嵌入式资源的子属性。

我在实例化要导出的报表时遇到了这个问题,必须像这样设置此属性:

wrvReport.LocalReport.ReportEmbeddedResource = "CommonLayer.Reports.SalesByPrice.rdlc";
我看到的区别是
。LocalReport
是设置嵌入式资源的子属性。

嵌入的报表资源是一个已定义的报表定义 作为资源存储在调用程序集中

如果已设置ReportPath属性,则ReportEmbeddedResource 属性被忽略

因此,设置EmbeddedResource属性实际上什么都不做,而ReportPath也会失败,因为它需要一个物理文件系统路径

嵌入的报表资源是一个已定义的报表定义 作为资源存储在调用程序集中

如果已设置ReportPath属性,则ReportEmbeddedResource 属性被忽略


因此,设置EmbeddedResource属性实际上什么都不做,而ReportPath也会失败,因为它需要一个物理文件系统路径

我也有同样的问题。我通过设置“Copy to Output Directory=Copy if newer”解决了这个问题。干杯。

我也有同样的问题。我通过设置“Copy to Output Directory=Copy if newer”解决了这个问题。干杯。

我也有同样的问题,这意味着您的代码找不到rdlc文件,您需要使用
report.ReportEmbeddedResource
report.ReportPath
。在我看来,查看您的代码似乎只需要使用
report.ReportEmbeddedResource
,另一个选项是针对位于pc中特定位置或网络文件系统中的rdlc

我也有同样的问题,这意味着您的代码找不到rdlc文件,您需要使用
report.ReportEmbeddedResource
report.ReportPath
。在我看来,查看您的代码似乎只需要使用
report.ReportEmbeddedResource
,另一个选项是针对位于pc或网络文件系统中特定位置的rdlc,请查看。请查看。为了澄清,嵌入的资源名称将以其嵌入的程序集的命名空间作为前缀。在我的例子中,对于业务程序集中名为Report1.rdlc的嵌入式资源,我需要
localReport.reportembeddedrource=“Business.Report1.rdlc”谢谢你为我指明了正确的方向!对于asp.net网站,请检查答案。希望这会有所帮助。为了澄清,嵌入的资源名称将以它所嵌入的程序集的名称空间作为前缀。在我的例子中,对于业务程序集中名为Report1.rdlc的嵌入式资源,我需要
localReport.reportembeddedrource=“Business.Report1.rdlc”谢谢你为我指明了正确的方向!对于asp.net网站,请检查答案。希望有帮助。