When I first used the reportviewer control I remember having some problems installing my app through ClickOnce. I kept getting annoying errors like the one below and the application wouldn’t install at all.
When you click on the details button, you’ll notice that some assemblies required for supporting the reportviewer control are missing. The assemblies are ADODB.dll, Microsoft.ReportViewer.Common.dll, Microsoft.ReportViewer.ProcessingObjectModel.dll and Microsoft.ReportViewer.WinForms.dll for windows forms applications.
Since these assemblies are not included by default into your ClickOnce installation package, in this post I’ll show you how to include them in your installation package so that you don’t get all these annoying errors.
When you are done developing your app and you are ready to publish via ClickOnce deployment, in Visual studio right click on your project and select Properties. Click the Publish button. You should see a screen like this.
Next step, click on the Application Files Button. The following screen will show up.
Now, notice that all the assemblies are shown but the Publish Status shows Prerequisite (Auto), which means the assemblies are required on the installation machine in order for the application to run successfully.
Change Publish Status for all the assemblies to Include as shown i the figure below. This will include the assemblies in your setup package and hence there will be no error when you install the application.
That is all there is to do. When you are done with this stage, click OK to all open dialogs, and just publish your application. When you install, you won’t have missing files errors.
Just in case the required assemblies are not visible in the application files list, you will need to manually add them to the project. To do this, go to your Project expoler, right click on your project and click properties.
On the properties page, click the References menu as shown in the figure below.
Click the Add button.
The following screen will be displayed.
Click on the .NET tab, and select the assembly you want to reference in your project, e.g. Adodb, and then click OK.
The assembly will be added to your peoject and now you can go back to the publish menu and then application files and include it as we have seen above.
After you publish, you can go to the publish location and verify that the assemblies have been included. See figure below that shows my publish location after publishing the application. Notice that all the assemblies I mentioned above, required for the reportviewer control to work are included.
It is as easy as that, and then your application will install nicely, and the reports you created will be viewable without problems, and your users will be happy. Isn’t that what we all dream about? Happy users?
Till next time. Yours truly.