Wednesday, October 03, 2012

Could not load file or assembly Microsoft.ReportViewer.WebForms

A colleague of mine got this error after deploying an application which uses the reporting services report viewer control.  By default when you add a reference to an assembly which resides in the GAC  it does not copy the dll to the local bin folder. So the application runs fine locally in debug mode however you then get this error when you deploy it to a server where the report viewer controls have  not been installed.

The easiest thing to do is to the change the reference in Visual Studio so that Copy Local is set to true so that the assembly gets copied to the bin directory when you do a build.

If you just want to deploy the report viewer dll rather than rebuild and deploy just copy it from the  C:\Windows\assembly directory to the deployed bin directory