Hi!
Some time ago I wrote a PS Module that generates reports based on a ReportViewer component. In that module I was using the following to load up the required assembly:
[ReflectionAssembly]::LoadWithPartialName(‘Microsoft.ReportViewer.WinForms’)
While it works fine, it depends on a ReportViewer redistributable being installed on a machine. Additionally, LoadWithPartialName method is being deprecated and I’d like to get rid of it. Basically I decided to update my PS module and wrap the latest version of ReportViewer DLLs (extracted from this package) into it (and load them up from my module folder when needed). This is where the problems begin:
- If I try loading the DLLs using Add-Type -Path @(<Array of paths to DLLs>) I am able to instantiate objects, etc. however in the end (when I'm calling LocalReport.Render() method I get an exception saying 'Could not load file or assembly 'Microsoft.ReportViewer.Common, Version...')
- If I try loading each DLL using [Reflection.Assembly]::Load([System.IO.File]::ReadAllBytes(<Path to DLL>)) I also get the exception, however this time it complains about the report definition file being invalid (which I know isn't true, since it works in identically implemented C# app, referencing those same DLLs).
As for the case #2, I’m not even sure what’s wrong there.
Does anyone have any ideas on how to achieve this?
Thanks in advance!