Recently some customers asked me how to use reportviewer 2010 in their visual studio 2008 project. ReportViewer 2010 fully supports both Visual Studio 2008 and Visual Studio 2010. The problem is that in Visual Studio 2008, you cannot directly use it in design time. This is a helpful hint, so I decided to dig it out. Really it works very well but need your efforts on extracting the DLLs from GAC and manually coding to create the reportviewer control. Here are my steps to show you how to make it work.
1. Download the ReportViewer 2010 Redistributable package from http://www.microsoft.com/downloads/details.aspx?FamilyID=a941c6b2-64dd-4d03-9ca7-4017a0d164fd&displaylang=en.
2. Install it on your computer, then the Microsoft.ReportViewer.WinForm.dll will be registered in GAC, however you could not directly reference this assembly from GAC in Visual Studio 2008. Referencing the assembly file is needed however the dll is not installed in other place. So the next step is how to extract the assembly file from the GAC.
3. John's blog showed some ways to extract assemblies from GAC. I used Windows Command Prompt to extract the Microsoft.ReportViewer.Winform.dll and Microsoft.ReportViewer. Common.dll out to my project's bin folder. You can first use the "cd" command to redirect the folder to " C:\Windows\assembly\GAC_MSIL\Microsoft.ReportViewer.WinForms", then use the "dir" command to check which folder is for ReportViewer 10.0 and run "cd" again to redirect to that folder, then run copy command like "copy Microsoft.ReportViewer.Winform.dll D:\Projects\MyTestReport\Bin\Microsoft.ReportViewer.Winform.dll" to copy the file to your project's bin folder. As well you can copy the Microsoft.ReportViewer. Common.dll file.
4. Then in Visual Studio 2008, right click the Reference folder, click "Add Reference...", switch to the Browse tab and add the references to these two assemblies. You can also add the ReportViewer control to the ToolBox via Choose Items by selecting the assembly Microsoft.ReportViewer.Winform.dll in the bin folder, but you will find that the control does not have real UI appearance. It just shows as a component but it is good since you can set properties via the property window.
5. Refer to those auto-generated code for the ReportViewer 2008 control in your project, manually add the code for your Reportviewer 2010 control to your Windows Form application accordingly.
6. For example, you have a form named Form1, modify the InitializeComponent function in Form1.Designer.cs as follows.
#region Windows Form Designer generated code
this.reportViewer1 = new Microsoft.Reporting.WinForms.ReportViewer();
Microsoft.Reporting.WinForms.ReportDataSource rds = new Microsoft.Reporting.WinForms.ReportDataSource();
private Microsoft.Reporting.WinForms.ReportViewer reportViewer1;
7. In the Form_Load event, you can fill the data to refresh your report just like ReportViewer 2008.
private void Form1_Load(object sender, EventArgs e)