asp.net - 尽管没有引用,但无法加载文件或程序集“Microsoft.ReportViewer.WebForms”
问题描述
我在我的 ASP.NET 项目中遇到过这个错误消息,但是这个最新的实例确实让我感到困惑,因为在我的项目中找不到任何对 ReportViewer 的引用。寻找有关如何确定其来源的任何建议。以下是堆栈跟踪信息:
[FileNotFoundException: Could not load file or assembly 'Microsoft.ReportViewer.WebForms, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +457
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +110
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +22
System.Reflection.Assembly.Load(String assemblyString) +34
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +48
[ConfigurationErrorsException: Could not load file or assembly 'Microsoft.ReportViewer.WebForms, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +729
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +69
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +226
System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +73
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +321
System.Web.Compilation.BuildManager.ExecutePreAppStart() +170
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +878
[HttpException (0x80004005): Could not load file or assembly 'Microsoft.ReportViewer.WebForms, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +525
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +124
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +700
解决方案
虽然我永远无法确定为什么会出现上述错误,但我发现了一种解决方法,方法是将一堆程序集从我在此服务器上的其他工作应用程序之一复制到项目的 \bin 文件夹中。这些组件包括:
Microsoft.ReportViewer.*
Microsoft.AI.Web
Microsoft.ApplicationInsights
Microsoft.AspNet.*
...和其他几个。我仍然困扰着为什么这甚至是必要的,因为代码不仅在我的开发机器上运行良好,而且在我第一次部署它的另一个测试 Web 服务器上运行良好。如果我的项目没有对这些东西的可验证引用,但仍然依赖于它们,那么我希望发布工具应该确保这些依赖项与我的其余代码一起部署。
推荐阅读
- mysql - MariaDB 使用 REGEXP 进行搜索
- php - 无法在视图中传递多表
- mongodb - MongoDb Where 子句中的嵌套查询
- javascript - 将一个数组的元素过滤到js中的另一个数组
- node.js - MongoDB Atlas 是否提供离线支持?
- javascript - 如何在html的弹出框中打印flask函数的输出?
- android - 对话框显示后如何从 RecyclerView 恢复刷过的项目?
- javascript - 我如何在 react-native 中使用条件运算符?发生此错误
- javascript - axios拦截器刷新token
- python - 构建 rom 枚举列表时出现意外的字典行为