简体   繁体   English

ASP.Net Core Angular项目中的程序集异常

[英]Assembly Exception in ASP.Net Core Angular project

I have an ASP.NET Core Angular web application. 我有一个ASP.NET Core Angular Web应用程序。 I created this project with Visual studio 2017 angular template. 我使用Visual Studio 2017角模板创建了这个项目。 I made a very basic application with the newest dependencies: 我制作了一个具有最新依赖关系的非常基本的应用程序:

  • Microsoft.AspNetCore.All (2.0.7) as NuGET Microsoft.AspNetCore.All(2.0.7)作为NuGET
  • Microsoft.NETCore.App (2.0.0) as SDK Microsoft.NETCore.App(2.0.0)作为SDK

We can build the application but when debugging , we encounter an exception as below: 我们可以构建应用程序,但是在调试时,会遇到如下异常:

System.IO.FileLoadException HResult=0x80131040 Message=Could not load file or assembly 'System.ComponentModel.Primitives, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. System.IO.FileLoadException HResult = 0x80131040消息=无法加载文件或程序集“ System.ComponentModel.Primitives,版本= 4.2.0.0,区域性=中性,PublicKeyToken = b03f5f7f11d50a3a”。 The located assembly's manifest definition does not match the assembly reference. 找到的程序集的清单定义与程序集引用不匹配。 (Exception from HRESULT: 0x80131040) (来自HRESULT的异常:0x80131040)
Source=Microsoft.Extensions.FileProviders.Physical 源= Microsoft.Extensions.FileProviders.Physical

Here is the StackTrace: 这是StackTrace:

StackTrace: at Microsoft.Extensions.FileProviders.PhysicalFileProvider.CreateFileWatcher(String root) at Microsoft.AspNetCore.Hosting.Internal.HostingEnvironmentExtensions.Initialize(IHostingEnvironment hostingEnvironment, String applicationName, String contentRootPath, WebHostOptions options) at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors) at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build() at WebApp.Program.BuildWebHost(String[] args) in D:\\Source\\WebApp\\Program.cs:line 21 at WebApp.Program.Main(String[] args) in D:\\Source\\WebApp\\Program.cs:line 17 StackTrace: Microsoft.Extensions.FileProviders.PhysicalFileProvider.CreateFileWatcher(String root) at Microsoft.AspNetCore.Hosting.Internal.HostingEnvironmentExtensions.Initialize(IHostingEnvironment hostingEnvironment, String applicationName, String contentRootPath, WebHostOptions options) at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors) at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build() at WebApp.Program.BuildWebHost(String[] args) in D:\\Source\\WebApp\\Program.cs:line 21 at WebApp.Program.Main(String[] args) in D:\\Source\\WebApp\\Program.cs:line 17

We tried going to older versions of ASP.NET Core and back. 我们尝试过使用旧版本的ASP.NET Core并返回。 The issue solves but next time we open the project the same exception happens. 问题解决了,但是下次我们打开项目时,也会发生同样的异常。 We cannot change the version of the Microsoft.NETCore.App (2.0.0) to newer versions because it is blocked by the project . 我们无法将Microsoft.NETCore.App(2.0.0)的版本更改为较新版本,因为它已blocked by the project

Note that we have changed the location of NugetPackages to be in specific folder (D:\\Source\\Library) (for the purpose of source control). 请注意,我们已将NugetPackages的位置更改为位于特定文件夹(D:\\ Source \\ Library)中(出于源代码控制的目的)。

Disable the runtime assembly specific on execution by adding the following to your project.json, under "frameworks": 通过在“ frameworks”下的project.json中添加以下内容,来禁用特定于执行的运行时程序集:

"System.ComponentModel.Primitives": {
  "version": "4.1.0", // or whatever version you have
  "exclude": "runtime"
},

This is a workaround. 这是一种解决方法。 It is happening because the platform-specific version of the System.ComponentModel.Primitives is not yet released for every platform - eg Ubuntu. 发生这种情况是因为尚未针对每个平台(例如Ubuntu)发布特定于平台的System.ComponentModel.Primitives版本。 More details here . 更多细节在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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