.net Winforms 无法在 VS2012 中加载文件或程序集“Microsoft.ReportDesigner,版本 = 10.0.0.0”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19287310/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Winforms Could not load file or assembly 'Microsoft.ReportDesigner, Version=10.0.0.0' in VS2012
提问by Stephan
This is driving me nuts. I have a winforms app build in VS2012 targeting .NET 4.5. On a few forms I have to use a ReportViewer. At first I worked with ReportViewer for 2012 (version 11.0.0.0). All working fine. However, my client doesn't want to install this version on their workstations yet because this version uses the CLR Types SQL 2012. Don't ask me why, but I have to accept this for now.
这让我发疯。我在 VS2012 中构建了一个针对 .NET 4.5 的 winforms 应用程序。在一些表单上,我必须使用 ReportViewer。起初,我在 2012 年使用 ReportViewer(版本 11.0.0.0)。一切正常。但是,我的客户还不想在他们的工作站上安装这个版本,因为这个版本使用 CLR Types SQL 2012。不要问我为什么,但我现在必须接受这个。
So I decided to use the previous reportviewer version 10.0.0.0. I downloaded the redistributional package and installed it. I also added it to my toolbox in VS2012 and deleted the reportviewer dll's already referenced in my project. But when I drag a version 10 reportviewer on my form I get the following error:
所以我决定使用以前的reportviewer 版本10.0.0.0。我下载了重新分发包并安装了它。我还在 VS2012 中将它添加到我的工具箱中,并删除了我的项目中已经引用的 reportviewer dll。但是,当我在表单上拖动版本 10 报表查看器时,出现以下错误:
Could not load file or assembly 'Microsoft.ReportDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
无法加载文件或程序集“Microsoft.ReportDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”或其依赖项之一。定位的程序集的清单定义与程序集引用不匹配。(来自 HRESULT 的异常:0x80131040)
The application IS running without errors, but I have no design-time support on the forms using this reportviewer control, as you can see in the image. I would like to get rid of the error.
应用程序正在运行且没有错误,但我对使用此报表查看器控件的表单没有设计时支持,如图所示。我想摆脱这个错误。


I checked the GAC and could not find the mentioned Microsoft.ReportDesigner. It is there for version 9.0.0.0 and 11.0.0.0 but not for 10.0.0.0.
我检查了 GAC 并找不到提到的 Microsoft.ReportDesigner。它适用于 9.0.0.0 和 11.0.0.0 版,但不适用于 10.0.0.0。
Bottom line, how can I use the ReportViewer version 10.0.0.0 in design time in VS2012 without the problem of the design-time error?
最重要的是,如何在 VS2012 的设计时使用 ReportViewer 版本 10.0.0.0 而不会出现设计时错误的问题?
Framework: .NET 4.5 App Type : winforms Language : vb.net Visual Studio: Version 2012 Control: ReportViewer 10.0.0.0 SP 1
框架:.NET 4.5 应用程序类型:winforms 语言:vb.net Visual Studio:版本 2012 控件:ReportViewer 10.0.0.0 SP 1
P.S. I also tested the ReportViewer control in VS2010, there is no problem using it in design time in VS2010.
PS我也在VS2010中测试了ReportViewer控件,在VS2010设计时使用是没有问题的。
[UPDATE]
[更新]
The exact error when I try to add the ReportViewer on my form in VS2012 is:
当我尝试在 VS2012 中的表单上添加 ReportViewer 时的确切错误是:


回答by Alex Kryvdyk
I had the same problem. I was able to fix VS 2012 designer with the following workaround. I doubt this is the correct way, but it helps and I did not find anything better for now.
我有同样的问题。我能够使用以下解决方法修复 VS 2012 设计器。我怀疑这是正确的方法,但它有帮助,我现在没有找到更好的方法。
Close Visual Studio 2012
Go to C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies folder and copy all report viewer assemblies (file names are starting with "Microsoft.ReportDesigner." and version is 10.0.0.0) to the C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PrivateAssemblies. Backup it before doing this.
Start Visual Studio 2012 and open your project.
关闭 Visual Studio 2012
转到 C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies 文件夹并将所有报表查看器程序集(文件名以“Microsoft.ReportDesigner.”开头,版本为 10.0.0.0)复制到 C :\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PrivateAssemblies。在执行此操作之前备份它。
启动 Visual Studio 2012 并打开您的项目。
回答by lomec
Alex's solution is wrong, it works but not right.
亚历克斯的解决方案是错误的,它有效但不正确。
Simply solution is replacing old refence with current version's dll
简单的解决方案是用当前版本的 dll 替换旧参考
I've removed removed reference Microsoft.ReportViewer.WinForms then added reference Microsoft.ReportViewer.WinForms which version is v11.0.0.0
我已经删除了删除引用 Microsoft.ReportViewer.WinForms 然后添加了引用 Microsoft.ReportViewer.WinForms 哪个版本是 v11.0.0.0
Hope it helps.
希望能帮助到你。
回答by dellyjm
Got the answer from CodeProject(see link below)
从CodeProject得到答案(见下面的链接)
It doesn't need a license, it's a Redistributable
它不需要许可证,它是可再发行的
2008 http://www.microsoft.com/en-us/download/details.aspx?id=6576[^]
2008 http://www.microsoft.com/en-us/download/details.aspx?id=6576[^]
2010 http://www.microsoft.com/en-us/download/details.aspx?id=6442[^]
2010 http://www.microsoft.com/en-us/download/details.aspx?id=6442[^]
http://www.codeproject.com/Questions/399003/Could-not-load-file-or-assembly-Microsoft-ReportVi
http://www.codeproject.com/Questions/399003/Could-not-load-file-or-assembly-Microsoft-ReportVi
回答by NCGrimbo
Alex's fix works, but you end up in the previous version of the control. To get the v11 of the report viewer control, close your project if it is open then browse to c:\windows\assembly. Copy the public key token's value for the Microsoft.ReportViewer.Common.Resource version 11.0.0.0. Open your project file and search for the reference to the 10.0.0.0 version of the ReportViewer. Change the version to 11.0.0.0 and the public key to the value you copied and then save the file. Once you open the project, the ReportViewer reference should be pointing to the correct version.
Alex 的修复有效,但您最终会使用该控件的先前版本。要获取报告查看器控件的 v11,请关闭您的项目(如果它已打开),然后浏览到 c:\windows\assembly。复制 Microsoft.ReportViewer.Common.Resource 版本 11.0.0.0 的公钥令牌值。打开您的项目文件并搜索对 ReportViewer 10.0.0.0 版本的引用。将版本更改为 11.0.0.0,将公钥更改为您复制的值,然后保存文件。打开项目后,ReportViewer 引用应该指向正确的版本。
回答by Dare Olaniyi Timothy
upload the the dll in your site bin
将 dll 上传到您的站点 bin 中
from this window folder(C:\Program Files (x86)\Microsoft Visual Studio 10.0\ReportViewer). i ve used it and it work
Microsoft.ReportViewer.Common.dllMicrosoft.ReportViewer.WebForms.dllMicrosoft.ReportViewer.WinForms.dll
从这个窗口文件夹(C:\Program Files (x86)\Microsoft Visual Studio 10.0\ReportViewer)。我用过它并且有效
Microsoft.ReportViewer.Common.dllMicrosoft.ReportViewer.WebForms.dllMicrosoft.ReportViewer.WinForms.dll
回答by Syed Shahid Amin
add reference with following path: C:\Windows\assembly\GAC_MSIL\Microsoft.ReportViewer.Common\12.0.0.0__89845dcd8080cc91\Microsoft.ReportViewer.Common.dll
添加以下路径的引用:C:\Windows\assembly\GAC_MSIL\Microsoft.ReportViewer.Common\12.0.0.0__89845dcd8080cc91\Microsoft.ReportViewer.Common.dll
C:\Program Files (x86)\Microsoft Visual Studio 14.0\ReportViewer\Microsoft.ReportViewer.WinForms.dll
C:\Program Files (x86)\Microsoft Visual Studio 14.0\ReportViewer\Microsoft.ReportViewer.WinForms.dll

