我正在尝试在 Raspberry Pi 上部署应用程序。我已经安装了 .NET Core 运行时,但在执行时出现此错误:
Unhandled Exception:
System.IO.FileNotFoundException: Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies.
File name: 'System.Diagnostics.DiagnosticSource, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
at Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.ApplyServices (Microsoft.EntityFrameworkCore.Infrastructure.IDbContextOptions options, Microsoft.Extensions.DependencyInjection.ServiceCollection services) [0x0003f] in <e66a1f96e9734a7fac7cea0901022728>:0
at Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache+<>c__DisplayClass4_0.<GetOrAdd>b__2 (System.Int64 k) [0x000fe] in <e66a1f96e9734a7fac7cea0901022728>:0
at (wrapper delegate-invoke) System.Func`2[System.Int64,System.ValueTuple`2[System.IServiceProvider,System.Collections.Generic.IDictionary`2[System.String,System.String]]].invoke_TResult_T(long)
at System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue].GetOrAdd (TKey key, System.Func`2[T,TResult] valueFactory) [0x00034] in <69599a71bc4d4cd3a8a6e4323fa57b86>:0
at Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.GetOrAdd (Microsoft.EntityFrameworkCore.Infrastructure.IDbContextOptions options, System.Boolean providerRequired) [0x000b7] in <e66a1f96e9734a7fac7cea0901022728>:0
at Microsoft.EntityFrameworkCore.DbContext..ctor (Microsoft.EntityFrameworkCore.DbContextOptions options) [0x00051] in <e66a1f96e9734a7fac7cea0901022728>:0
at Microsoft.EntityFrameworkCore.DbContext..ctor () [0x00006] in <e66a1f96e9734a7fac7cea0901022728>:0
at XPathParserTest1.Model..ctor () [0x00000] in <51b90b049f2c424c9ef8e7dced3213d4>:0
at XPathParserTest1.Program.MainAsync (System.String[] args) [0x001a2] in <51b90b049f2c424c9ef8e7dced3213d4>:0
at XPathParserTest1.Program.Main (System.String[] args) [0x00015] in <51b90b049f2c424c9ef8e7dced3213d4>:0
相同的项目文件在使用 SDK 的 Windows 上运行良好,而仅使用运行时清理 Windows。
我不知道发生了什么,我尝试了一些解决方案,包括编辑 csproj 文件和更改 nuget 依赖项。
最佳答案
对于 Raspbian,如果官方支持,最好为可执行文件生成 native 镜像
关于c# - 无法使用 .NET Core 在 Raspbian 上加载文件或程序集 'System.Diagnostics.DiagnosticSource',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54871903/