Мой проект работает нормально на Windows P C, но если запустить его на RPI 4 с Raspbian, я не смогу прочитать раздел в моих настройках приложения. json.
public void ConfigureServices(IServiceCollection services)
{
Console.WriteLine("ConfigureServices");
...
Console.WriteLine("Before AuthSettings");
var authSettingsSection = Configuration.GetSection("AuthSettings");
services.Configure<AuthSettings>(authSettingsSection);
Console.WriteLine("Read AuthSettings");
// configure jwt authentication
var authSettings = authSettingsSection.Get<AuthSettings>();
Console.WriteLine(authSettings.Secret);
...
}
I получите исключение Null Reference, если я хочу прочитать запись authSettings.Secret
.
Так что похоже, что Configuration.GetSection
не работает.
Вот вывод:
pi@raspberrypi:~ $ sudo dotnet /usr/share/nginx/webapi/abc.dll
ConfigureServices
Before AuthSettings
Read AuthSettings
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at abc.Startup.ConfigureServices(IServiceCollection services) in C:\Users\me\Source\Repos\abc\abc\Startup.cs:line 55
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.InvokeCore(Object instance, IServiceCollection services)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass9_0.<Invoke>g__Startup|0(IServiceCollection serviceCollection)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.Invoke(Object instance, IServiceCollection services)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass8_0.<Build>b__0(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.UseStartup(Type startupType, HostBuilderContext context, IServiceCollection services)
at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass12_0.<UseStartup>b__0(HostBuilderContext context, IServiceCollection services)
at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
at Microsoft.Extensions.Hosting.HostBuilder.Build()
at abc.Program.Main(String[] args) in C:\Users\me\Source\Repos\abc\abc\Program.cs:line 16
Aborted
Я опубликовал API как Self contained
в linux-arm
Есть идеи?
С наилучшими пожеланиями!