代码之家  ›  专栏  ›  技术社区  ›  Jake

发布RDLC文件

  •  28
  • Jake  · 技术社区  · 14 年前

    Microsoft.Reporting.WinForms.ReportViewer rvReportViewer;
    /* ... */
    rvReportViewer.LocalReport.ReportPath = string.Format("Reports/{0}.rdlc", ReportName);
    

    我已经尝试将这些文件的构建操作设置为“Resource”,这是我对静态图像文件所做的,但这似乎没有任何区别。

    谢谢!

    4 回复  |  直到 14 年前
        1
  •  44
  •   oddmeter    12 年前

    我不知道RDLC文件是否有特殊的问题,但是这里有一个确保其他文件被发布的一般方法。

    在解决方案资源管理器中右键单击该文件,然后选择“属性”。将“Build Action”设置为“Content”,将“Copy to output Directory”设置为“Copy if newer”。

    转到项目属性->发布页面。点击“应用程序文件按钮”,选中“显示所有文件”。将“发布状态”设置为“包含(自动)”

    文件属性

    File Properties

    Publish Properties

        2
  •  36
  •   R. Schreurs Rohith    11 年前

    我使用@nos的答案已经有一段时间了,但我注意到在出版物中,.rdlc文件集被复制到两个地方:

    1. 原webapplication项目的相对位置;
    2. 在bin文件夹中。

     1. <published folder>\Reports\Report1.rdlc;
     2. <published folder>\bin\Reports\Report1.rdlc.
    

    我并不打算在第二个位置使用rdlc的副本,事实上,如果我删除这些副本,仍然会生成报告。

    我将每个rdlc文件的设置更改为:

    Build Action: Content;
    Copy to Output Directory: Do not copy.
    

        3
  •  9
  •   tbirangi    9 年前

    抱歉,伙计们,这与“总是复制”或“更新时复制”无关。事实上,我把它设置为“从不复制”。 通过将构建操作从“嵌入式资源”更改为“内容”,可以解决此问题。然后,当您构建和发布RLDC文件时,会将其复制到正确的位置。

        4
  •  2
  •   KirstieBallance    5 年前

    1. **使用以下代码:

    reportViewer1.LocalReport.ReportEmbeddedResource="[Project
    Name].[FolderName if Exist].[ReportName].rdlc";
    
    1. 然后重建部署项目。