未找到rdlc定义 [英] rdlc definition not found

查看:66
本文介绍了未找到rdlc定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我在Web服务中有一种方法可以呈现.rdlc报告:

        [OperationContract]
        public byte [] getReportData()
        {
            string reportType =" Excel";            string mimeType,                  编码,                   filenameExtension;
           警告[]警告;
            string [] streams;
            byte [] renderedBytes;

            DataSet ds = new DataSet();
            SqlConnection conn = new SqlConnection(connectionString);
            SqlCommand cmd1 = new SqlCommand(" GetDataNew",conn);
            cmd1.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter daReport = new SqlDataAdapter(cmd1);
            daReport.Fill(ds," SalesData");

            ReportDataSource RDS =新ReportDataSource(QUOT; dsTestReport" ;, ds.Tables [" SALESDATA"]);

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP; string deviceInfo ="< DeviceInfo> < OUTPUTFORMAT> Excel的< / OUTPUTFORMAT> <页宽> 8.5in< /页宽> < PageHeight> 11英寸< / PageHeight> < MarginTop> 0.5英寸< / MarginTop> < MarginLeft> 1英寸< / MarginLeft> < MarginRight> 1英寸< / MarginRight> < MarginBottom> 0.5英寸< / MarginBottom> < / DeviceInfo>";            LocalReport rep = new LocalReport();
            rep.ReportEmbeddedResource = QUOT; SalesVolume.Web.SalesVolume.rdlc英寸;
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; rep.DisplayName =" Sales Volume Report";            rep.DataSources.Add(rDs);

            renderedBytes = rep.Render(reportType,deviceInfo,out mimeType,out encoding,out filenameExtension,out streams,out warnings);

         &NBSP;&NBSP;&NBSP; return renderingBytes;
       客户端是一个Siverlight Web应用程序,它将字节流写入磁盘:

        &NBSP;&NBSP;&NBSP;&NBSP; dbClient.getReportDataAsync();

            SaveFileDialog saveDialog = new SaveFileDialog();
            saveDialog.Filter =" Excel Files(* .xls)| * .xls";

            if(saveDialog.ShowDialog()== true)
            {
               使用(Stream stream = saveDialog.OpenFile())
                {
&n&n;                  stream.Write(reportStream,0,reportStream.Length);
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP; stream.Flush();
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; stream.Close();
                }           我的目标是将rdlc报告呈现给excel文件。它适用于我的开发计算机,我点击"渲染报告"。按钮,silverlight应用程序打开一个保存文件对话框并将excel报告保存到磁盘。没问题。
当我部署到QA服务器时,我在Web服务方法上出错,返回的字节流为空。我认为由于某种原因,Web服务没有找到嵌入式资源。
有任何建议吗?

Hello, I have a method in a web service that renders an .rdlc report:

        [OperationContract]
        public byte[] getReportData()
        {
            string reportType = "Excel";
            string mimeType,
                   encoding,
                   filenameExtension;
            Warning[] warnings;
            string[] streams;
            byte[] renderedBytes;

            DataSet ds = new DataSet();
            SqlConnection conn = new SqlConnection(connectionString);
            SqlCommand cmd1 = new SqlCommand("GetDataNew", conn);
            cmd1.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter daReport = new SqlDataAdapter(cmd1);
            daReport.Fill(ds, "SalesData");

            ReportDataSource rDs = new ReportDataSource("dsTestReport", ds.Tables["SalesData"]);

            string deviceInfo = "<DeviceInfo> <OutputFormat>Excel</OutputFormat> <PageWidth>8.5in</PageWidth> <PageHeight>11in</PageHeight> <MarginTop>0.5in</MarginTop> <MarginLeft>1in</MarginLeft> <MarginRight>1in</MarginRight> <MarginBottom>0.5in</MarginBottom> </DeviceInfo>";


            LocalReport rep = new LocalReport();
            rep.ReportEmbeddedResource = "SalesVolume.Web.SalesVolume.rdlc";
            rep.DisplayName = "Sales Volume Report";
            rep.DataSources.Add(rDs);

            renderedBytes = rep.Render(reportType, deviceInfo, out mimeType, out encoding, out filenameExtension, out streams, out warnings);

            return renderedBytes;
        }


The client is an Siverlight web app that writes the byte stream to disk:

            dbClient.getReportDataAsync();

            SaveFileDialog saveDialog = new SaveFileDialog();
            saveDialog.Filter = "Excel Files (*.xls)|*.xls";

            if (saveDialog.ShowDialog() == true)
            {
                using (Stream stream = saveDialog.OpenFile())
                {
                    stream.Write(reportStream, 0, reportStream.Length);
                    stream.Flush();
                    stream.Close();
                }

            }

My goal is to render the rdlc report to an excel file. It works in my development computer, I click the "Render Report" button, the silverlight app opens a save file dialog and saves the excel report to disk. No problem.
When I deploy to the QA server I get an error on the web service method and the returned byte stream is null. I think that for some reason the web service is not finding the embedded resource.
Any suggestions?

推荐答案

这可能是一个权限问题你的数据库连接。使用VS开发服务器时,工作进程具有当前用户(您)的上下文。如果您的用户上下文可以访问数据库连接,那么连接将成功。但是,当您部署到IIS服务器时,将在IIS管理控制台中配置工作进程的用户上下文。默认用户上下文因IIS版本而异,但无论如何,它都必须具有在代码中执行SQL语句的权限。

我会尝试将IIS中工作进程的用户上下文更改为您的用户,然后测试并查看是否成功。

This might be a permissions issue for your database connection. When you use the VS development server, the worker process has the context of the current user (you). And if your user context has access to the database connection, then connection will succeed. But when you deploy to an IIS server, then the user context of the worker process is configured in the IIS management console. The default user context varies depending on your IIS version, but whatever it is, it must have the rights to execute the SQL statements in your code.

I would try changing the user context of the worker process in IIS to your user, then test and see if it succeeds.


这篇关于未找到rdlc定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆