GGMG-he-him
GGMG-he-him

Reputation: 394

Could not load assembly Microsoft.ReportViewer.Common, despite installing the prerequisites

So, I've got a C# windows workflow project that creates a report programmatically and emails it out. It works fine on my local machine, but putting it on a scheduler in a different machine generates the following error:

Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Based on other topics, I tried installing MICROSOFT® REPORT VIEWER 2012 RUNTIME from the following address: http://www.microsoft.com/en-us/download/details.aspx?id=35747. This didn't help. This was the overwhelmingly prevalent solution, but I'd love any other suggestions or advice.

Upvotes: 1

Views: 28271

Answers (3)

jp2code
jp2code

Reputation: 188

I experienced this problem just today after updating ReportViewer.Common.

The new version did not have folders for the different languages like the old version did, but the project still had them shown in the bin folder. When I tried compiling, I got an error because they were not there.

How I fixed it: From the Solution Explorer, I selected the various language folder and hit DELETE.

screenshot

In NuGet Package Manager, I also updated a lot of my old packages. The old packages were still in the project and the new packages were not. So, I added the new ones and deleted the old.

solutionExplorerScreenshot

It seemed like a very manual process - something I'm not used to doing with Visual Studio.

I had to rebuild the project, but after that I was able to publish.

Upvotes: 0

Jon Dysinger
Jon Dysinger

Reputation: 191

The accepted answer pointed me in the right direction. However, didn't provide enough details for me to reach resolution. I wanted to add this as a comment to that answer but it was too long.

In my VS project, I had a reference to Microsoft.ReportViewer.WinForms version 12.0.0.0 and when deploying to another computer got the same error as present in this question. The key to the problem is a portion of the error:

The located assembly's manifest definition does not match the assembly reference.

It is telling you that it found a DLL with the right name, but it is the wrong version. I had added a reference to Microsoft.ReportViewer.Common through the references dialog but I didn't catch that the only one listed in the "Extensions" section of the references dialog was for version 10.0.0.0. So of course it will deploy the wrong one if you are telling it to deploy the wrong one.

What you have to do is find the Microsoft.ReportViewer.Common.dll file with version 12.0.0.0 on your system and manually include a reference to that. For me it was in the following directory:

C:\Windows\assembly\GAC_MSIL\Microsoft.ReportViewer.Common\12.0.0.0__89845dcd8080cc91\

Once I added that reference and set both DLLs to Copy Local in my VS project, then everything worked on the deployed machine.

Note: I did not require an installation of the Microsoft Report Viewer 2012 Runtime in order to have it work on the deployed machine. For any of you like me that were wanting to avoid any other installations during deployment.

Upvotes: 4

Yaser
Yaser

Reputation: 95

try to add the dll files to the project from : C:\Program Files\Microsoft Visual Studio 10.0\ReportViewer add them to the bin folder after publishing the project

Upvotes: 0

Related Questions