Visual Studio .NET进入2005版本以后,Crystal Report与IDE的结合更“紧密”了,至少我们看不到那个讨厌的注册窗口了。但是,Microsoft似乎并不容忍在自己的超级工具中竟然没有报表工具,于是Report Viewer Control出现了,我把它的报表称为RDLC报表
在VS .NET 2005之前,SQL Server Reporting Services中已经提供了一种被称为报表定义语言(Report Definition Language, RDL)的语言;在VS .NET 2005中,Microsoft提供了针对这种报表的设计器,并提供了在WinForm和WebForm中使用这种报表的能力。Microsoft将这种报表的后缀定为RDLC,RDL仍然是Report Definition Language的缩写,那么C代表什么呢?C代表Client-side processing,凸显了它的客户端处理能力。
这么写貌似有点长啊....简略点吧.不会RDLC的 先搞个C/S的WINDOS应用程序先练练手,教程百度.然后再搞个web winfrom 练练手,操作有点不一样.
把数据搞出来了,下面再接着干.
参考链接:
步骤:
先新建一个项目 用ASP.NET Web 窗体应用程序 创建;然后将你希望完成的报表在里面实现如下图.
界面如图:
效果如下:
在MVC4的项目才是我们的主项目,上面那个只是为了测试RDLC功能是否正常能用,否则在MVC4中直接搞,太麻烦了.
然后拷贝文件到MVC4中.如图所示 拷贝RDLC文件夹,拷贝WebForm1.aspx
剩下就是配置一些参数了.
直接运行看下报什么错,然后根据错误配置该配置的就好了. 一般根据需要配置下面俩个其中之一.具体看界面错误有提示的.
还有路由别忘记设置了.列外不能用MVC4的访问模式
效果如下:
本地测试通过了.别急放到服务器上还有一堆错误等着你呢!!!
错误记录我都已经记录如下,自己参考着解决.
想查看一下SharePoint的Microsoft.SharePoint.Library.DLL, 可是发现这个文件被安装在了GAC中. 如何才能拿到这个DLL, 反汇编一下玩玩呢?GAC的目录在c:\windows\assembly, 而这个目录是不允许你直接复制粘贴的. 为了把文件拿出来, 你需要使用命令行.
如果你使用命令行的话, 你会发现GAC的目录结构与Windows Explorer展示给你的看的目录不同.
要把文件从GAC中拿到, 你可以运行下面的命令:
C:\WINDOWS\assembly\GAC_MSIL>xcopy *.* C:\GACDLLs\ /s /r
具体程序集所在的目录也许会不同. 有可能是GAC 或者是GAC_32. 先找到你想要的文件, 然后你可能会需要从上面列出的文件夹中进行拷贝.
具体操作
win+r
cmd
cd C:\WINDOWS\assembly\GAC_MSIL>
xcopy *.* C:\GACDLLs\ /s /r
问:designer.cs 不自动生成
答:拷贝文件到MVC项目中选中文件,右键[转换为web应用程序]
问:错误 1 命名空间“Microsoft”中不存在类型或命名空间名称“Reporting”(是否缺少程序集引用?)E:\开发\装箱系统\Web_Up20151116\Web\AppPallet\AppPallet\RDLC\Default.aspx.designer.cs5733AppPallet
答:添加引用 Microsoft.ReportViewer.WebForms(引用前需要核对版本如图)
=========================发布错误=========================
Server Error in '/' Application.
--------------------------------------------------------------------------------
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Could not load file or assembly 'Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. 系统找不到指定的文件。
Source Error:
Line 27: <system.web>
Line 28: <httpHandlers>
Line 29: <add verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
Line 30: </httpHandlers>
Line 31: <compilation targetFramework="4.0" />
Source File: E:\OA_Npp_Pro测试\web.config Line: 29
Assembly Load Trace: The following information can be helpful to determine why the assembly 'Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' could not be loaded.
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
解决方案:
拷贝 C:\GACDLLs\Microsoft.ReportViewer.WebForms\11.0.0.0__89845dcd8080cc91 目录下的 Microsoft.ReportViewer.WebForms.dll 文件到网站发布bin目录下
=========================发布错误=========================
Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. 系统找不到指定的文件。 Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. 系统找不到指定的文件。Source Error: The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:1. Add a "Debug=true" directive at the top of the file that generated the error. Example: <%@ Page Language="C#" Debug="true" %>or:2) Add the following section to the configuration file of your application:<configuration> <system.web> <compilation debug="true"/> </system.web></configuration>Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario. Assembly Load Trace: The following information can be helpful to determine why the assembly 'Microsoft.ReportViewer.Common, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' could not be loaded.WRN: Assembly binding logging is turned OFF.To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.Note: There is some performance penalty associated with assembly bind failure logging.To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].Stack Trace: [FileNotFoundException: Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. 系统找不到指定的文件。] Microsoft.Reporting.WebForms.LocalReport..ctor() +0 Microsoft.Reporting.WebForms.ReportHierarchy..ctor(ServerReport serverReport) +120 Microsoft.Reporting.WebForms.ReportViewer.CreateReportHierarchy() +51 Microsoft.Reporting.WebForms.ReportViewer..ctor() +281 ASP.webforms_webform1_aspx.__BuildControlReportViewer1() +33 ASP.webforms_webform1_aspx.__BuildControlform1() +999 ASP.webforms_webform1_aspx.__BuildControlTree(webforms_webform1_aspx __ctrl) +189 ASP.webforms_webform1_aspx.FrameworkInitialize() +29 System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +54 System.Web.UI.Page.ProcessRequest() +78 System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21 System.Web.UI.Page.ProcessRequest(HttpContext context) +49 ASP.webforms_webform1_aspx.ProcessRequest(HttpContext context) +4 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +100 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75--------------------------------------------------------------------------------Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.504
解决方案: 拷贝 C:\GACDLLs\Microsoft.ReportViewer.Common\11.0.0.0__89845dcd8080cc91 下Microsoft.ReportViewer.Common.dll 到bin目录下即可
=========================发布错误=========================
An error occurred during local report processing.
The report definition for report 'Report1' has not been specified
Could not find file 'E:\OA_Npp_Pro测试\RDLC\Report1.rdlc'.
解决方案: 拷贝Report1.rdlc'. 文件到 服务器 rdlc 目录下
=========================发布错误=========================
An error occurred during local report processing.
The definition of the report 'RDLC\Report1.rdlc' is invalid.
An unexpected error occurred in Report Processing.
Could not load file or assembly 'Microsoft.SqlServer.Types, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. 系统找不到指定的文件。
解决方案:
拷贝 C:\GACDLLs\Microsoft.SqlServer.Types\11.0.0.0__89845dcd8080cc91 目录下 Microsoft.SqlServer.Types.dll 到服务器发布bin目录下
=========================发布错误=========================
An error occurred during local report processing.
The definition of the report 'RDLC\Report1.rdlc' is invalid.
An unexpected error occurred in Report Processing.
Could not load file or assembly 'Microsoft.ReportViewer.ProcessingObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. 系统找不到指定的文件。
解决方案:
拷贝 C:\GACDLLs\Microsoft.ReportViewer.ProcessingObjectModel\11.0.0.0__89845dcd8080cc91 目录下 Microsoft.ReportViewer.ProcessingObjectModel.DLL 到发布目录bin 下
=========================发布错误=========================
Server Error in '/' Application.
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: The file '/RDLC/Default.aspx.cs' does not exist.
Source Error:
Line 1: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
Line 2:
Line 3: <%@ Register assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>
Source File: /RDLC/Default.aspx Line: 1
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34280
=========================发布错误=========================
Report Viewer Configuration Error
The Report Viewer Web Control HTTP Handler has not been registered in the application's web.config file. Add <add verb="*" path="Reserved.ReportViewerWebControl.axd" type = "Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" /> to the system.web/httpHandlers section of the web.config file, or add <add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" /> to the system.webServer/handlers section for Internet Information Services 7 or later.