1

I have a reference to these assemblies in my MVC project Microsoft.ReportViewer.WebForms Microsoft.ReportViewer.Common

Version is 11.0 but I set it to SpecificVersion = False and CopyLocal = False

But upon deploying, I keep getting this error:

Could not load file or assembly 'Microsoft.ReportViewer.WebForms, Version=11.0.0.0,

The available versions in GAC are 10.0 and 12.0 but I thought it should simply load whatever is this (hopefully 12.0 since it's the latest one) since I set CopyLocal to false. What am I doing wrong here? Is there a best practice for this since we don't really know what version will the clients have in their GAC but we want to support both versions.

  • Could you please have a look at my answer on [Could not load file or assembly 'Microsoft.ReportViewer.Common, Version...](http://stackoverflow.com/questions/22253607/could-not-load-file-or-assembly-microsoft-reportviewer-common-version-11-0-0-0/33670464#33670464)? – Murat Yıldız Apr 24 '16 at 21:05

1 Answers1

0

SpecificVersion = False is only a hint for the compiler. Once compiled, your project is bound to a specific version of that assembly.

Since different assembly versions could have differences that are not compatible with each other, it is not safe to just pick any available version.

Solutions:

  • Support just one ReportViewer version
  • Have different projects for different ReportViewer versions
  • Use reflection
  • Use binding redirects
Community
  • 1
  • 1
Lars Truijens
  • 42,837
  • 6
  • 126
  • 143
  • Thank you. Correct me if I'm wrong, but adding binding redirects would still not allow me to default to version 12 but in the case that it does not exists, it would use version 11. We are not supporting more than 2 versions of the reportviewer so I'm trying to find a way to do this with minimal effort if that is possible. – user1039024 Feb 18 '16 at 21:01
  • If you compile against version 12, you could redirect version 12 at runtime to version 11. But yes, if version 12 is installed, the redirects should be removed. – Lars Truijens Feb 18 '16 at 21:16
  • Thanks a lot for your help. – user1039024 Feb 18 '16 at 22:32