ReportViewer 14:“针对.NET Framework 4.0

时间:2017-09-04 13:48:23

标签: .net reference .net-4.0 reportviewer nuget-package

我在Windows窗体应用程序中安装了ReportViewer 14 NuGet包(针对.NET Framwork 4.0):Microsoft.ReportingServices.ReportViewerControl.Winforms(V. 140.340.80;最新稳定版)

构建时,我收到了几条类似于以下内容的警告:

  

主要参考“Microsoft.ReportViewer.Design,Version = 14.0.0.0,Culture = neutral,PublicKeyToken = 89845dcd8080cc91,processorArchitecture = MSIL”无法解析,因为它对程序集“Microsoft.VisualStudio.Shell”具有间接依赖性.14.0,Version = 14.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a“这是针对”.NETFramework,Version = v4.5“框架构建的。这是比当前目标框架“.NETFramework,Version = v4.0”更高的版本。

应用程序构建成功,一切似乎都有效,但我仍然很少关注警告。

我不确定它是否与操作系统有关,但是:我正在运行Windows 7,我的同事在Windows 10上并且没有看到问题(两者都是Visual Studio 2017)

不幸的是,我们目前与.NET Framework 4.0绑定,因为我们必须支持某些Windows XP客户端。

更新

我创建了一个新的空的.NET 4.0项目,并且收到相同但更少的警告(这次仅影响“ [.NET] Framework程序集”)。

以下是来自vanilla项目的完整警告列表:

1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1987,5): warning MSB3268: The primary reference "Microsoft.ReportViewer.Design" could not be resolved because it has an indirect dependency on the framework assembly "System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "Microsoft.ReportViewer.Design" or retarget your application to a framework version which contains "System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1987,5): warning MSB3258: The primary reference "Microsoft.ReportViewer.Design" could not be resolved because it has an indirect dependency on the .NET Framework assembly "Microsoft.Build.Framework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which has a higher version "14.0.0.0" than the version "4.0.0.0" in the current target framework.
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1987,5): warning MSB3268: The primary reference "Microsoft.ReportViewer.Design" could not be resolved because it has an indirect dependency on the framework assembly "System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "Microsoft.ReportViewer.Design" or retarget your application to a framework version which contains "System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1987,5): warning MSB3268: The primary reference "Microsoft.ReportViewer.Design" could not be resolved because it has an indirect dependency on the framework assembly "System.Threading.Tasks, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "Microsoft.ReportViewer.Design" or retarget your application to a framework version which contains "System.Threading.Tasks, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1987,5): warning MSB3268: The primary reference "Microsoft.ReportViewer.Design" could not be resolved because it has an indirect dependency on the framework assembly "System.Diagnostics.Tracing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "Microsoft.ReportViewer.Design" or retarget your application to a framework version which contains "System.Diagnostics.Tracing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1987,5): warning MSB3268: The primary reference "Microsoft.ReportViewer.Design" could not be resolved because it has an indirect dependency on the framework assembly "System.Collections.Concurrent, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "Microsoft.ReportViewer.Design" or retarget your application to a framework version which contains "System.Collections.Concurrent, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1987,5): warning MSB3268: The primary reference "Microsoft.ReportViewer.Design" could not be resolved because it has an indirect dependency on the framework assembly "System.Dynamic.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "Microsoft.ReportViewer.Design" or retarget your application to a framework version which contains "System.Dynamic.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1987,5): warning MSB3268: The primary reference "Microsoft.ReportViewer.Design" could not be resolved because it has an indirect dependency on the framework assembly "System.Collections, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "Microsoft.ReportViewer.Design" or retarget your application to a framework version which contains "System.Collections, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1987,5): warning MSB3268: The primary reference "Microsoft.ReportViewer.Design" could not be resolved because it has an indirect dependency on the framework assembly "System.Threading, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "Microsoft.ReportViewer.Design" or retarget your application to a framework version which contains "System.Threading, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1987,5): warning MSB3268: The primary reference "Microsoft.ReportViewer.Design" could not be resolved because it has an indirect dependency on the framework assembly "System.Resources.ResourceManager, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "Microsoft.ReportViewer.Design" or retarget your application to a framework version which contains "System.Resources.ResourceManager, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1987,5): warning MSB3268: The primary reference "Microsoft.ReportViewer.Design" could not be resolved because it has an indirect dependency on the framework assembly "System.Globalization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "Microsoft.ReportViewer.Design" or retarget your application to a framework version which contains "System.Globalization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1987,5): warning MSB3268: The primary reference "Microsoft.ReportViewer.Design" could not be resolved because it has an indirect dependency on the framework assembly "System.Diagnostics.Debug, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "Microsoft.ReportViewer.Design" or retarget your application to a framework version which contains "System.Diagnostics.Debug, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1987,5): warning MSB3268: The primary reference "Microsoft.ReportViewer.Design" could not be resolved because it has an indirect dependency on the framework assembly "System.Runtime.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "Microsoft.ReportViewer.Design" or retarget your application to a framework version which contains "System.Runtime.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1987,5): warning MSB3268: The primary reference "Microsoft.ReportViewer.Design" could not be resolved because it has an indirect dependency on the framework assembly "System.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "Microsoft.ReportViewer.Design" or retarget your application to a framework version which contains "System.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1987,5): warning MSB3268: The primary reference "Microsoft.ReportViewer.Design" could not be resolved because it has an indirect dependency on the framework assembly "System.Diagnostics.Tools, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "Microsoft.ReportViewer.Design" or retarget your application to a framework version which contains "System.Diagnostics.Tools, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1987,5): warning MSB3268: The primary reference "Microsoft.ReportViewer.Design" could not be resolved because it has an indirect dependency on the framework assembly "System.Reflection, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "Microsoft.ReportViewer.Design" or retarget your application to a framework version which contains "System.Reflection, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".

2 个答案:

答案 0 :(得分:1)

我终于能够解决它了:

TL; DR

核心问题似乎分别是 Visual Studio 2015 的安装 SQL Server Management Studio 17.2 :在卸载所有组件之后,警告是走了!

答案很长

我注意到的第一件事是,MSBuild抱怨的程序集(例如Microsoft.VisualStudio.Shell.14.0)安装在我的全局程序集缓存(GAC)中,而它们并不在我的同事PC上。我通过在Developer Command Prompt中运行以下内容来验证:

gacutil /l Microsoft.VisualStudio.Shell.14.0

所以必须在GAC中安装这些程序集。

版本号" 14"指向Visual Studio 2015的方向(因为它的内部版本号是Visual Studio v14)。所以我卸载了所有有" Visual Studio 2015"以其名义 - 包括

  • Visual Studio 2015 Shell(隔离)和
  • SQL Server Management Studio 17.2(因为我知道SSMS基本上是一个Visual Studio扩展,并且正在安装" Shell" -Version of VS旁边)

解决了所有警告问题。

(我假设MSBuild正在使用适用于.NET 4.0的参考程序集,而不是适用于GAC的目标4.5)

要仔细检查我的发现,我重新安装了SQL Server Management Studio 17.2,其中包括 VS2015 Shell(隔离) - 并返回了警告。 再卸载一次后,它们又消失了。

这不是一个完全令人满意的解决方案,因为我不能再安装SSMS了。

答案 1 :(得分:0)

我已通过删除所有对“ Microsoft.ReportViewer.Design”的引用来解决此问题

(此引用由报表查看器NuGet包添加。在VS2010 / VS2015中,我从未使用过该引用,也从未在我的应用程序中分发该dll。)

所以对我来说解决方案如下:

  • VS 2017,SSMS 17.x均已安装
  • 面向.net 4.0的Winform应用程序
  • 添加了报表查看器块软件包和“ Visual Studio的Microsoft rdlc报表设计器”扩展名
  • 手动删除Microsoft.RepotViewer.Design参考
  • 我的应用程序仅包含本地报告:VS报告设计器将旧格式(vs2010)的rdlc文件和一些经过修订的rdlc文件转换为最新的rdlc。
  • 应用程序可以正常编译而不会发出警告,并且可以在开发机器上正常运行。
  • 我的WIX安装程序仅安装以下与报告相关的组件:Microsoft.ReportViewer.Common.dll,Microsoft.ReportViewer.DataVisualization.dll,Microsoft.ReportViewer.ProcessingObjectModel.dll,Microsoft.ReportViewer.WinForms.dll,Microsoft.SqlServer.Types .dll

在win10上进行了测试,没有任何问题。

压力测试在带有.net 4.0的全新XP SP3上进行了测试:报告运行正常。