在 MVC 4 中使用RDLC 报表

2023-10-28

前期知识点

RDLC 报表

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 练练手,操作有点不一样.

把数据搞出来了,下面再接着干.


参考链接:

http://www.csdn123.com/html/itweb/20130813/57034_57018_57042.htm               http://www.cnblogs.com/devv/archive/2013/08/13/3255343.html
http://www.codeproject.com/Articles/609580/Prototype-MVC4-Razor-ReportViewer-RDLC
http://www.ekeol.com/forum/10612
http://www.cnblogs.com/wuhuacong/p/4109833.html
http://jingyan.baidu.com/article/ab69b270ff9c6e2ca7189f0e.html


步骤:

先新建一个项目 用ASP.NET Web 窗体应用程序 创建;然后将你希望完成的报表在里面实现如下图.


界面如图:


效果如下:




MVC4

在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.


本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在 MVC 4 中使用RDLC 报表 的相关文章

  • velocity 语法简记

    前几天接触了一个相对老一些的项目 渲染模板用的velocity 之前并没有接触过这个模板 所以也难免踩了踩坑 现在把页面上用到的一些语法总结一下 包括if for set等 希望可以给同道中人带来一点点帮助 说明 velocity使用 作为
  • Mac之parallels安装centos显示操作失败

    Mac之parallels安装centos显示操作失败 Parallels17安装遇到网络和操作失败 Parallels Desktop17 1 1安装经常遇到网络初始化失败和操作失败问题 可以根据下面提供方案进行解决 网络初始化失败处理方
  • f@()的意思

    表示 f 为函数句柄 是定义句柄的运算符 1 一维函数 f x acos x 相当于建立了一个函数文件 f m function y f x y acos x 是匿名函数的意思 函数句柄的使用方法也和函数是一样的 2 二维函数 3 仅表示函
  • 登陆界面的前台与后台

    JSP页面 1 form表单提交到 通过name 传递input数据 2 servlet request去get 这个name 3 servlet 得到数据后将多个表单数据set到对象中 调用对象定义方连接数据库去实现数据的核对操纵判断是否
  • 剑指 Offer 20. 表示数值的字符串(java+python)

    请实现一个函数用来判断字符串是否表示数值 包括整数和小数 数值 按顺序 可以分成以下几个部分 若干空格 一个 小数 或者 整数 可选 一个 e 或 E 后面跟着一个 整数 若干空格 小数 按顺序 可以分成以下几个部分 可选 一个符号字符 或
  • 使用python抓取liaoxuefeng网站正文和目录

    本文档参考了该博客和其源代码 不过为了方便 我没有使用beautifulsoup和pdfkit 而是直接通过python自带的HTMLParser来处理html 然后解析出html中的主体内容 然后重新生成一个新的html 并重命名为章节内
  • 【单片机毕业设计】【mcuclub-dz-054】基于单片机的多功能密码锁控制系统设计

    最近设计了一个项目基于单片机的多功能密码锁控制系统设计 与大家分享一下 一 基本介绍 项目名 基于单片机的多功能密码锁的设计 单片机 STM32F103C8T6 功能简介 1 通过4 4的矩阵键盘中的0 9为数字键 为删除键 为确定键 A为
  • 蓝牙mesh消息中的三种model: server models、client models、control models

    server models 服务器模型是在设备上运行的一个软件组件 负责管理和存储设备的状态信息 同时接受来自客户端的请求并进行响应 服务器模型定义了设备的功能和行为 并向网络中的其他设备发布其状态信息 比如发布一些state的消息 cli
  • Alexandru Popescu谈InfoQ.com网站架构

    概要 在QCon伦敦2008会议的采访中 InfoQ首席架构师Alexandru Popescu谈论了InfoQ的架构 WebWork与DWR的集成 Hibernate与JCR Hibernate可扩展性 MySQL拷贝 最新 InfoQ视
  • Java实现龟兔赛跑

    使用继承Thread的方式来实现龟兔赛跑游戏 我们首先来看一下需求 开始编写代码 首先我们创建一个动物抽象类Animal 在Animal中定义一个runing的抽象方法 注意 这里面有一个回调方法 定义它的目的就是当任意一方跑完200m后
  • [区块链]以太坊手动添加静态节点

    如果每次都向某个节点同步区块 可以手动的添加为静态节点 这样可以大大的提高同步效率 这里套用一下https blog csdn net weixin 40903789 article details 79619646的私链 感谢 我就不用再
  • Android服务创建步骤是什么,Android Service详解(二)---StartService

    一丶概述 启动服务由另一个组件通过调用 startService 启动 这会导致调用服务的 onStartCommand 方法 服务启动之后 其生命周期即独立于启动它的组件 并且可以在后台无限期地运行 即使启动服务的组件已被销毁也不受影响
  • 【unity3D】DoTween动画插件(下)

    未来的游戏开发程序媛 现在的努力学习菜鸡 本专栏是我关于游戏开发的学习笔记 本篇是unity的DoTween动画插件可视化编辑 DoTween动画插件 可视化编辑 DOTween Animation DoTween Path路径编辑器 Sc
  • IBM Spectrum LSF Documentation

    原文链接 https www ibm com docs en spectrum lsf 10 1 0 topic o w 2 This is the IBM LSF online help documentation
  • java中request接收数组(即request接收多个同名参数)

    例如 复选框 勾选多个内容的时候 提交
  • 区块链对于实体经济将发挥什么样的作用

    区块链技术被誉为颠复时代的技术之一 有望推动整个实体经济的技术 框架 效率以及模式的变革 如此光环之下的区块链技术被给予厚望 也处于舆论的刀剑上 不论是区块链技术的何种应用被发掘 总能引起社会各界的广泛关注 以平和的角度去看区块链 不外乎就

随机推荐

  • IDEA 值得推荐的优秀插件分享

    IDEA可以说是目前市面上 比较好用的编程软件之一 想必各位程序大佬们也都有用过 这要得益于它炫酷的UI界面 强大的功能 以及可以下载丰富的插件 帮助我们编程开发 提升我们的工作效率等等 之前也有朋友和同事 询问我有没有好用的插件推荐 正好
  • docker快速学习--dockerfile--05

    一 Docker 镜像原理 1 1 操作系统组成部分 1 2 镜像原理 Docker镜像是由特殊的文件系统叠加而成 最底端是 bootfs 并使用宿主机的bootfs 第二层是 root文件系统rootfs 称为base image 然后再
  • 制作一个简单的网页(入门篇)

    使用HTML和CSS来制作一个简单的网页 前言 一 HTML 1 1常见元素介绍 1 2借助工具 浏览器开发者工具 二 实现个人名片 1 基本框架 2 使用CSS美化 1 CSS书写位置 1 以元素的style 属性来指定 内联样式 2 以
  • 快速排序递归实现和非递归实现(详解)

    内容 快速排序的递归 非递归实现代码及注解 思路详解 以及快速排序的优化 目录 快速排序的递归实现 基本思想 步骤 让基准值排序到最终位置 使得左右区间自然分割开的方法有如下三种 1 hoare版本 基本思想 编辑动图演示 一些细节 代码实
  • dvwa靶场Brute Force(暴力破解)全难度教程(附代码分析)

    建议使用owaspbwa靶场可以不用搭建dvwa以及其他常用靶场 省去搭建靶场的困扰 但是此靶机靶场较老 并不建议使用 owaspbwa下载地址 OWASP Broken Web Applications Project download
  • 【C++奇遇记】函数模板

    博客主页 博主链接 本文由 M malloc 原创 首发于 CSDN 学习专栏推荐 LeetCode刷题集 数据库专栏 初阶数据结构 欢迎点赞 收藏 留言 如有错误敬请指正 未来很长 值得我们全力奔赴更美好的生活 文章目录 本章详情 函数模
  • XML的生成和解析

    一 什么是XML XML就是可扩展标记语言 HTML是超文本标记语言 标记语言就是通过一个一个的标记来组织数据的一种语法格式 与HTMl超文本语言比较的话XML这种可扩展语言它的标记是自己定义的 XML中自己定义的标记表示 例如 lt 标记
  • 复杂网络博弈:WS、NW小世界网络模型

    用Matlab程序分别绘制含有至少100个节点的WS NW小世界网络模型 并给出具体程序代码 带每行注释 Matlab版本 matlab R2022b 代码1 自己不用去创建函数体 设置节点数量为100 N 100 设置平均度数为4 K 4
  • 如何编写jstl自定义标签(示例:自定义jstl Long型时间转为date型)

    原文地址 http www cnblogs com icoding archive 2012 07 08 2581164 html 写jsp不可避免的会用到jstl 因为这个公司也没怎么用过velocity等模板 所以jstl就相对来说是比
  • 幼儿园分班问题 【Java】

    幼儿园分班问题 Java 题目描述 幼儿园两个班的小朋友在排队时混在了一起 每位小朋友都知道自己是否与前面一位小朋友是否同班 请你帮忙把同班的小朋友找出来 小朋友的编号是整数 与前一位小朋友同班用Y表示 不同班用N表示 输入描述 输入由空格
  • LaTeX 宏包(\usepackage)

    LaTeX 宏包引用及常用宏包简介 LaTeX 宏包 宏包介绍 常用宏包简介 如何安装宏包 MiKTeX Console 宏包调用 LaTeX 宏包 宏包介绍 宏包是用来扩展 增强LaTeX的功能 宏包与LaTeX的关系和浏览器插件与浏览器
  • hbuilderX自定义主题仿vscode暗黑主题

    目录 hbuilderX自定义主题仿vscode暗黑主题 效果图 设置方式 把主题代码复制进来即可 是基于雅蓝主题自定义的 设置好后需要切换到雅蓝主题 hbuilderx保存时自动整理代码 1 首先在顶部栏 找到工具 打开设置 2 点击旁边
  • net::ERR_CONNECTION_RESET 报错原因

    1 gt 向tomcat 服务器上上传视频 谷歌浏览器控制台报出 打开信地址栏后 发现 net ERR CONNECTION RESET 错误 但是此视频以经过mp4转码 注 浏览器支持的播放mp4视频编码格式为 AVC编码的H264 后发
  • Unity 打包至Android 平台 编译不通过 所遇到过的坑

    Now we are here to learn how to build a android app by unity game engine but Build 不出来咋办 你都遇到了那些情况的问题呢 1 入门 忘记设置包名 2 安装A
  • Intellj idea 中创建测试 test

    在idea中创建测试类有两种方法 1 鼠标点中类名 使用 Alt Enter 会弹出intention action gt create tests 2 鼠标点中类名 使用 Ctrl Shift T 默认 会弹出 create new te
  • 在uniapp微信小程序中实现无限级评论(vue递归组件+Java构建所有评论树状结构)

    1 前言 这是本人毕业设计中其中一个功能点 就是用户在微信小程序 使用uniapp框架 中的首页模块中可以对健身资讯进行评论或者社区模块对别人发布的动态进行评论 2 实现效果 最后放个演示视频吧 实现思路 1 首先 在前端页面中编写好一个递
  • 制作PCB的基本设计流程;

    基本流程 1 在电脑中建立一个自定义的文件夹 例如D AD project Project1 以备存储设计文件用 双击打开Altium Designer 进入软件工作界面 2 创建工程文件 单击 File 菜单 选择 New 选项中的 Pr
  • [知识/工具/安全渗透测试]简洁明了的Google Hacking教程,效率UPUP

    Google Hacking 简介 Google Hacking 是指利用谷歌搜索引擎中的高级操作符 在搜索结果中定位特定的文本字符串 依托于谷歌强大的后台爬虫数据库 灵活使用可大大提高效率 前排提醒 请遵守法律法规 科学上网 不要用于非法
  • 语音合成技术

    转自 https zhuanlan zhihu com p 27395458 语音合成又称文语转换 Text To Speech 简称TTS 指通过机械的 电子的方法生成语音的技术 随着科技的发展 合成语音的自然度和音质均得到了明显的改善
  • 在 MVC 4 中使用RDLC 报表

    前期知识点 RDLC 报表 Visual Studio NET进入2005版本以后 Crystal Report与IDE的结合更 紧密 了 至少我们看不到那个讨厌的注册窗口了 但是 Microsoft似乎并不容忍在自己的超级工具中竟然没有报