We're currently using a Windows Service to generate PDF files. I was recently optimizing the code and noticed the abusive use of memory. This was caused by the lack of a using statement around var reportViewer = new ReportViewer()
However, after adding this the code threw a runtime nullreference exception after closing the using block, the code originating in the internal Dispose method.
Why does this error occur and how can I dispose the object properly?