我在Ubuntu服务器(16.04.1 LTS(GNU / Linux 4.4.0-97-generic x86_64))中提供了几个aspnet核心应用程序,这些应用程序总是运行得很好,它们的webapi配置非常相似,但昨天我发布其中一个问题(只是一个其他工作就像一个魅力),我收到一个错误,老实说,我不明白,因为我不记得做了任何与错误信息有关的变化,我浪费了很多时间,我会疯了。我最近将aspnet核心版本从1.1升级到2.0。
这是我的Program.cs
public class Program
{
public static void Main(string[] args)
{
Console.Title = "Webtools Service";
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args)
{
var config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("hosting.json", true)
.Build();
return WebHost.CreateDefaultBuilder(args)
.UseKestrel()
.UseConfiguration(config)
.ConfigureAppConfiguration((hostContext, conf) =>
{
var env = hostContext.HostingEnvironment;
// delete all default configuration providers
conf.Sources.Clear();
conf.SetBasePath(env.ContentRootPath);
conf.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
conf.AddJsonFile("appsettings.local.overrides.json", optional: true);
conf.AddEnvironmentVariables();
})
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
//.UseApplicationInsights()
.Build();
}
}
我附上错误跟踪:
> info:
> Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
> User profile is available. Using '/home/ubuntu/.aspnet/DataProtection-Keys' as key repository; keys
> will not be encrypted at rest. Application startup exception:
> System.PlatformNotSupportedException: Windows Principal functionality
> is not supported on this platform. at
> System.Security.Principal.WindowsIdentity.GetCurrent() at
> Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.Implementation.ApplicationFolderProvider..ctor(IDictionary
> environment, String folderName) at
> Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.Implementation.Transmitter.Initialize()
> at
> Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel.Initialize(TelemetryConfiguration
> configuration) at
> Microsoft.Extensions.DependencyInjection.TelemetryConfigurationOptionsSetup.Configure(TelemetryConfiguration
> configuration) at
> Microsoft.Extensions.DependencyInjection.TelemetryConfigurationOptions..ctor(IEnumerable`1
> configureOptions)
> --- End of stack trace from previous location where exception was thrown --- at
> System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite
> constructorCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite
> callSite, TArgument argument) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite
> scopedCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite
> singletonCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite
> callSite, TArgument argument) at
> Microsoft.Extensions.DependencyInjection.ServiceProvider.<>c__DisplayClass22_0.<RealizeService>b__0(ServiceProvider
> provider) at
> Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type
> serviceType) at
> Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider
> provider) at
> Microsoft.Extensions.DependencyInjection.ApplicationInsightsExtensions.<>c.<AddApplicationInsightsTelemetry>b__13_1(IServiceProvider
> provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite
> factoryCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite
> callSite, TArgument argument) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite
> scopedCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite
> singletonCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite
> callSite, TArgument argument) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite
> constructorCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite
> callSite, TArgument argument) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite
> scopedCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite
> singletonCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite
> callSite, TArgument argument) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite
> constructorCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite
> callSite, TArgument argument) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite
> scopedCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite
> singletonCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite
> callSite, TArgument argument) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitIEnumerable(IEnumerableCallSite
> enumerableCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite
> callSite, TArgument argument) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite
> constructorCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite
> callSite, TArgument argument) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite
> scopedCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite
> singletonCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite
> callSite, TArgument argument) at
> Microsoft.Extensions.DependencyInjection.ServiceProvider.<>c__DisplayClass22_0.<RealizeService>b__0(ServiceProvider
> provider) at
> Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type
> serviceType) at
> Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider
> provider) at
> Microsoft.ApplicationInsights.AspNetCore.ApplicationInsightsStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder
> app) at
> Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication() crit:
> Microsoft.AspNetCore.Hosting.Internal.WebHost[6]
> Application startup exception System.PlatformNotSupportedException: Windows Principal functionality
> is not supported on this platform. at
> System.Security.Principal.WindowsIdentity.GetCurrent() at
> Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.Implementation.ApplicationFolderProvider..ctor(IDictionary
> environment, String folderName) at
> Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.Implementation.Transmitter.Initialize()
> at
> Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel.Initialize(TelemetryConfiguration
> configuration) at
> Microsoft.Extensions.DependencyInjection.TelemetryConfigurationOptionsSetup.Configure(TelemetryConfiguration
> configuration) at
> Microsoft.Extensions.DependencyInjection.TelemetryConfigurationOptions..ctor(IEnumerable`1
> configureOptions)
> --- End of stack trace from previous location where exception was thrown --- at
> System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite
> constructorCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite
> callSite, TArgument argument) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite
> scopedCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite
> singletonCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite
> callSite, TArgument argument) at
> Microsoft.Extensions.DependencyInjection.ServiceProvider.<>c__DisplayClass22_0.<RealizeService>b__0(ServiceProvider
> provider) at
> Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type
> serviceType) at
> Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider
> provider) at
> Microsoft.Extensions.DependencyInjection.ApplicationInsightsExtensions.<>c.<AddApplicationInsightsTelemetry>b__13_1(IServiceProvider
> provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite
> factoryCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite
> callSite, TArgument argument) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite
> scopedCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite
> singletonCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite
> callSite, TArgument argument) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite
> constructorCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite
> callSite, TArgument argument) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite
> scopedCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite
> singletonCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite
> callSite, TArgument argument) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite
> constructorCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite
> callSite, TArgument argument) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite
> scopedCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite
> singletonCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite
> callSite, TArgument argument) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitIEnumerable(IEnumerableCallSite
> enumerableCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite
> callSite, TArgument argument) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite
> constructorCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite
> callSite, TArgument argument) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite
> scopedCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite
> singletonCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite
> callSite, TArgument argument) at
> Microsoft.Extensions.DependencyInjection.ServiceProvider.<>c__DisplayClass22_0.<RealizeService>b__0(ServiceProvider
> provider) at
> Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type
> serviceType) at
> Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider
> provider) at
> Microsoft.ApplicationInsights.AspNetCore.ApplicationInsightsStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder
> app) at
> Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
>
> Unhandled Exception: System.PlatformNotSupportedException: Windows
> Principal functionality is not supported on this platform. at
> System.Security.Principal.WindowsIdentity.GetCurrent() at
> Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.Implementation.ApplicationFolderProvider..ctor(IDictionary
> environment, String folderName) at
> Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.Implementation.Transmitter.Initialize()
> at
> Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel.Initialize(TelemetryConfiguration
> configuration) at
> Microsoft.Extensions.DependencyInjection.TelemetryConfigurationOptionsSetup.Configure(TelemetryConfiguration
> configuration) at
> Microsoft.Extensions.DependencyInjection.TelemetryConfigurationOptions..ctor(IEnumerable`1
> configureOptions)
> --- End of stack trace from previous location where exception was thrown --- at
> System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite
> constructorCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite
> callSite, TArgument argument) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite
> scopedCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite
> singletonCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite
> callSite, TArgument argument) at
> Microsoft.Extensions.DependencyInjection.ServiceProvider.<>c__DisplayClass22_0.<RealizeService>b__0(ServiceProvider
> provider) at
> Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type
> serviceType) at
> Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider
> provider) at
> Microsoft.Extensions.DependencyInjection.ApplicationInsightsExtensions.<>c.<AddApplicationInsightsTelemetry>b__13_1(IServiceProvider
> provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite
> factoryCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite
> callSite, TArgument argument) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite
> scopedCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite
> singletonCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite
> callSite, TArgument argument) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite
> constructorCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite
> callSite, TArgument argument) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite
> scopedCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite
> singletonCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite
> callSite, TArgument argument) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite
> constructorCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite
> callSite, TArgument argument) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite
> scopedCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite
> singletonCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite
> callSite, TArgument argument) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitIEnumerable(IEnumerableCallSite
> enumerableCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite
> callSite, TArgument argument) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite
> constructorCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite
> callSite, TArgument argument) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite
> scopedCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite
> singletonCallSite, ServiceProvider provider) at
> Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite
> callSite, TArgument argument) at
> Microsoft.Extensions.DependencyInjection.ServiceProvider.<>c__DisplayClass22_0.<RealizeService>b__0(ServiceProvider
> provider) at
> Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type
> serviceType) at
> Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider
> provider) at
> Microsoft.ApplicationInsights.AspNetCore.ApplicationInsightsStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder
> app) at
> Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication() at
> Microsoft.AspNetCore.Hosting.WebHostBuilder.Build() at
> WebtoolsService.Program.BuildWebHost(String[] args) in
> /var/NetWebApps/sources/Program.cs:line 26 at
> WebtoolsService.Program.Main(String[] args) in
> /var/NetWebApps/sources/Program.cs:line 16