简体   繁体   中英

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.

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.

尝试将dll文件添加到项目中:C:\\ Program Files \\ Microsoft Visual Studio 10.0 \\ ReportViewer在发布项目后将它们添加到bin文件夹

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM