Friday, 28 September 2007

XCopy install of ReportViewer assemblies

A recent project at work was a Console C# application that used .Net 2.0's LocalReport class to generate letters. To ease deployment, I prefer to distribute an application via copying instead of using an installer. A frequent problem for users of the LocalReport class is that it requires three assemblies that are not part of the .Net 2.0 Framework (but confusingly, are part of VS 2005). Whilst these assemblies can be installed (to the GAC) via Microsoft's ReportViewer re-distributable (SP1), this breaks the principle of an xcopy install. The solution of course is to locate the required assemblies and mark them as CopyLocal in the project that requires them.

This should be no problem of course, as the first two assemblies show up in the .Net reference list:
  • Microsoft.ReportViewer.WinForms.dll
  • Microsoft.ReportViewer.Common.dll
Inspection of the second using Reflector reveals the third to be:
  • Microsoft.ReportViewer.ProcessingObjectModel.dll
which Reflector fails to locate - but why, if has been successfully installed? Even a search of the System partition fails to locate it.

The answer is the platform agnostic GAC (%SystemRoot%\assembly\GAC_MSIL). Its contents are seemingly invisible to searching: the only way to access them is:
  1. Via the command-shell, e.g. via a command-prompt, cd/explorer into %SystemRoot%\assembly\GAC_MSIL.
  2. Via Microsoft's gacutil.exe.

Doing this allows you to locate the third assembly at:
  • %SystemRoot%\assembly\GAC_MSIL\Microsoft.ReportViewer.ProcessingObjectModel\
It can then be copied somewhere visible to the project (e.g. the application's lib directory) and added to the list of CopyLocal dependencies.


odelmotte said...


Have you encountered some problems using SubReports with this methods.

I found the solution you explain here by my way (copy from GAC).

My problem is that I use a SubReport in my xCopy deployed application.

The Main report works well, but the subreport fails when I run my app on a user computer, while on my own workstation, all is fine.

Do you have an idea ?

Lyndsay said...

Thanks for your comment. I'm afraid that I haven't worked with SubReports in this way, so can't help on this one.