I just started to write reporting software in new version of visual studio named visual studio 2017 RC but just noticed that core reportviewing tools is missing from both windows forms and WPF application template. Can anyone tell me why the reportviewer tool is disappeared from visual studio 2017 ? Really having trouble without it . Is there any alternate to work with this tool in new visual studio ?
问题:
回答1:
Update: Microsoft released a document on 4/18/2017 describing how to configure and use the reporting tool in Visual Studio 2017.
Visual Studio 2017 does not have the ReportViewer
tool installed by default in the ToolBox. Installing the extension Microsoft Rdlc Report Designer for Visual Studio and then adding that to the ToolBox results in a non-visual component that appears below the form.
Microsoft Support had told me this is a bug, but as of 4/21/2017 it is "working as designed".
The following steps need to be followed for each project that requires ReportViewer
.
- If you have
ReportViewer
in the Toolbox, remove it. Highlight, right-click and delete.- You will have to have a project with a form open to do this.
- If you have the Microsoft Rdlc Report Designer for Visual Studio extension installed, uninstall it.
- Close your solution and restart Visual Studio. This is a crucial step, errors will occur if VS is not restarted when switching between solutions.
- Open your solution.
- Open the NuGet Package Manager Console (
Tools/NuGet Package Manager/Package Manager Console
) At the PM> prompt enter this command, case matters.
Install-Package Microsoft.ReportingServices.ReportViewerControl.WinForms
You should see text describing the installation of the package.
Now we can temporarily add the ReportViewer
tool to the tool box.
Right-click in the toolbox and use
Choose Items...
We need to browse to the proper DLL that is located in the solutions
Packages
folder, so hit the browse button.In our example we can paste in the packages folder as shown in the text of Package Manager Console.
C:\Users\jdoe\Documents\Projects\_Test\ReportViewerTest\WindowsFormsApp1\packages
Then double click on the folder named
Microsoft.ReportingServices.ReportViewerControl.Winforms.140.340.80
The version number will probably change in the future.
Then double-click on
lib
and again onnet40
.Finally, double click on the file
Microsoft.ReportViewer.WinForms.dll
You should see
ReportViewer
checked in the dialog. Scroll to the right and you will see the version 14.0.0.0 associated to it.Click OK.
ReportViewer
is now located in the ToolBox.
Drag the tool to the desired form(s).
Once completed, delete the
ReportViewer
tool from the tool box. You can't use it with another project.You may save the project and are good to go.
Remember to restart Visual Studio any time you need to open a project with ReportViewer
so that the DLL is loaded from the correct location. If you try and open a solution with a form with ReportViewer
without restarting you will see errors indicating that the “The variable 'reportViewer1' is either undeclared or was never assigned.
“.
If you add a new project to the same solution you need to create the project, save the solution, restart Visual Studio and then you should be able to add the ReportViewer
to the form. I have seen it not work the first time and show up as a non-visual component.
When that happens, removing the component from the form, deleting the Microsoft.ReportViewer.*
references from the project, saving and restarting usually works.
回答2:
Please NOTE that this procedure of adding the reporting services described by @Rich Shealer above will be iterated every time you start a different project. In order to avoid that:
If you may need to set up a different computer (eg, at home without internet), then keep your downloaded installers from the marketplace somewhere safe, ie:
- Microsoft.DataTools.ReportingServices.vsix, and
- Microsoft.RdlcDesigner.vsix
Fetch the following libraries from the packages or bin folder of the application you have created with reporting services in it:
- Microsoft.ReportViewer.Common.dll
- Microsoft.ReportViewer.DataVisualization.dll
- Microsoft.ReportViewer.Design.dll
- Microsoft.ReportViewer.ProcessingObjectModel.dll
- Microsoft.ReportViewer.WinForms.dll
Install the 2 components from 1 above
- Add the dlls from 2 above as references (Project>References>Add...)
- (Optional) Add Reporting tab to the toolbar
- Add Items to Reporting tab
- Browse to the bin folder or where you have the above dlls and add them
You are now good to go! ReportViewer icon will be added to your toolbar, and you will also now find Report and ReportWizard templates added to your Common list of templates when you want to add a New Item... (Report) to your project
NB: When set up using Nuget package manager, the Report and ReportWizard templates are grouped under Reporting. Using my method described above however does not add the Reporting grouping in installed templates, but I dont think it is any trouble given that it enables you to quickly integrate rdlc without internet and without downloading what you already have from Nuget every time!