Assets file project.assets.json not found. Run a NuGet package restore
编译报错,一般是工程下的obj
文件夹被删除了,或者格式损坏了,在工程所在目录运行
dotnet restore
即可解决,或者在VS的解决方案上右键,点击Restore NuGet Packages
即可
Could not load file or assembly ‘System.Diagnostics.PerformanceCounter, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51’. 系统找不到指定的文件
运行时报错,
- 原因:
使用的是.Net Core进行开发,但是在运行时引用了第三方库,而第三方库使用的是.Net Framework,此第三方库中使用了PerformanceCounters模块,而在.Net Core环境中是没有此模块的,导致报错
- 解决:
使用兼容.Net Core的第三方库即可
以下是解决问题过程中查阅的文档:
https://github.com/dotnet/corefx/issues/3906 .Net Core issues, 还有https://github.com/microsoft/ApplicationInsights-aspnetcore/issues/470ApplicationInsights-aspnetcore的issues,里有提到.Net Core目前是不支持 PerformanceCounter模块的,预计在.Net Core 2.8中发布
Windows -1252 is not supported encoding name,System.NotSupportedException: No data is available for encoding 1252
环境: .Net Core 2.2,WebApi,
这个是在使用配置文件中的数据库连接字符串时,MySQL模块抛的异常,其实配置文件使用的是UTF-8
格式,代码环境也是Unicode环境,不应该出现这个报错,经过查文档,
安装:System.Text.Encoding.CodePages
库以及System.Text.Encoding
库(可以通过NuGet Manager安装)
然后在程序启动的入口处加上:
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
问题解决,估计是因为 .Net Core中默认是没有字符编码解析的库的,需要额外安装,.Net Framework中是有这 两个库的;
参考自 stackoverflow问题:https://stackoverflow.com/questions/32471058/windows-1252-is-not-supported-encoding-name