Asp.net mvc 部署MVC时,为什么向我抛出一个错误本地报表服务?

Asp.net mvc 部署MVC时,为什么向我抛出一个错误本地报表服务?,asp.net-mvc,asp.net-mvc-4,reporting-services,Asp.net Mvc,Asp.net Mvc 4,Reporting Services,一些罕见的事情正在发生 在我的rdlc报告中,我将一些文本框设置为在MVC4项目中显示为PDF格式,如果我在localhost模式下运行它,它的效果非常好 但是如果我部署了解决方案,就会抛出以下错误 参数无效。[ArgumentException:参数无效。] System.Drawing.Graphics.GetHdc()+1144409 Microsoft.ReportingServices.Rendering.RichText.LineBreaker.Flow(文本框 文本框、图形g、Fo

一些罕见的事情正在发生

在我的rdlc报告中,我将一些文本框设置为在MVC4项目中显示为PDF格式,如果我在localhost模式下运行它,它的效果非常好

但是如果我部署了解决方案,就会抛出以下错误

参数无效。[ArgumentException:参数无效。] System.Drawing.Graphics.GetHdc()+1144409
Microsoft.ReportingServices.Rendering.RichText.LineBreaker.Flow(文本框 文本框、图形g、FontCache FontCache、FlowContext FlowContext、, 布尔龙骨,单高)+57
Microsoft.ReportingServices.Rendering.RichText.TextBox.MeasurelHeight(文本框 文本框、图形g、FontCache FontCache、FlowContext FlowContext、, 单个和内容高度)+500
Microsoft.ReportingServices.Rendering.HPBProcessing.TextBox.DetermineVerticalSize(PageContext pageContext、Double-topInParentSystem、Double-bottomInParentSystem等

[LocalProcessingException:本地报告期间发生错误 正在处理。]
Microsoft.Reporting.WebForms.LocalReport.InternalRender(字符串格式, 布尔AllowinerRenders、字符串设备信息、PageCountMode pageCountMode,CreateAndRegisterStream createStreamCallback, 警告[]和警告)+338
Microsoft.Reporting.WebForms.LocalReport.InternalRender(字符串格式, 布尔AllowinerRenders、字符串设备信息、PageCountMode

注意:我注意到如果删除我的rdlc中的文本框(我的意思是删除所有东西),会生成一个空白的PDF。因此,我意识到文本框是个问题,但我不知道为什么只有在部署时才会出现

我错过了什么

我使用的代码是下一个:

    public ActionResult SampleReport()
    {
        LocalReport localReport = new LocalReport();
        localReport.ReportPath = Server.MapPath("~/Reports/Report1.rdlc");

        string reportType = "PDF";
        string mimeType;
        string encoding;
        string fileNameExtension;

        //The DeviceInfo settings should be changed based on the reportType
        //http://msdn2.microsoft.com/en-us/library/ms155397.aspx
        string deviceInfo =
        "<DeviceInfo>" +
        "  <OutputFormat>PDF</OutputFormat>" +
        "  <PageWidth>8.5in</PageWidth>" +
        "  <PageHeight>11in</PageHeight>" +
        "  <MarginTop>0.5in</MarginTop>" +
        "  <MarginLeft>1in</MarginLeft>" +
        "  <MarginRight>1in</MarginRight>" +
        "  <MarginBottom>0.5in</MarginBottom>" +
        "</DeviceInfo>";

        Warning[] warnings;
        string[] streams;
        byte[] renderedBytes;

        //Render the report
        renderedBytes = localReport.Render(
            reportType,
            deviceInfo,
            out mimeType,
            out encoding,
            out fileNameExtension,
            out streams,
            out warnings);
        //Response.AddHeader("content-disposition", "attachment; filename=NorthWindCustomers." + fileNameExtension);
        return File(renderedBytes, mimeType);
    }
public ActionResult sampleport()
{
LocalReport LocalReport=新建LocalReport();
localReport.ReportPath=Server.MapPath(“~/Reports/Report1.rdlc”);
string reportType=“PDF”;
字符串模拟类型;
字符串编码;
字符串文件名扩展名;
//应根据报告类型更改DeviceInfo设置
//http://msdn2.microsoft.com/en-us/library/ms155397.aspx
字符串设备信息=
"" +
“PDF”+
“8.5英寸”+
“11英寸”+
“0.5英寸”+
“1英寸”+
“1英寸”+
“0.5英寸”+
"";
警告[]警告;
字符串[]流;
字节[]渲染字节;
//提交报告
renderedBytes=localReport.Render(
报告类型,
deviceInfo,
输出mimeType,
输出编码,
输出文件名扩展名,
流出的溪流,
发出警告);
//AddHeader(“内容处置”、“附件;文件名=NorthWindCustomers.”+文件名扩展名);
返回文件(renderdbytes,mimeType);
}
更新: 当我开始研究如何使用Report Services创建PDF时,我只遵循以下指南:

最后一个是因为,我必须包含其中三个作为引用库,
Microsoft.ReportViewer.Common
Microsoft.ReportViewer.WebForms
Microsoft.ReportViewer.ProcessingObjectModel
,因为部署时,我的解决方案不计入这些库,所以我手动添加了它们


就是这样!

如果您在此处包含错误,而不是链接(将来可能会腐烂),则会有所帮助。此外,如果您告诉我们您迄今为止为解决此问题所做的尝试和研究将有所帮助。@Jeroen我已添加了更多信息,如果您认为我遗漏了什么,请告诉我我在部署到azure网站时遇到了同样的问题。。您也在使用azure,对吗?我猜reportviewer的实现很糟糕,azure没有“我不接受。@Flores我在Azure网站应用程序(web作业?)中使用了此功能,但当我将其移动到Azure网站时,我遇到了与上述相同的错误。有人找到了解决方案吗?我们的解决方案是从reportviewer移走,我们现在使用MvcRazorToPdf。”