Centos Linux自包含(SCD)ASP.NET Core应用程序启动例外

时间:2018-12-16 19:27:01

标签: asp.net-core asp.net-core-mvc asp.net-core-2.0 centos7 sigabrt

所有英雄,您好:)我是Linux的新手。我使用身份创建了一个.net核心Web应用程序。我要发布自我包含。我安装了所有必需的linux库。授予文件系统权限。它在我的本地虚拟机上运行。但是在我的洋地黄滴上却没有。 :(请帮助我。

这是我调用可执行文件时的控制台输出。

  

信息:Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager [0]         用户个人资料可用。使用“ /root/.aspnet/DataProtection-Keys”作为密钥存储库;密钥不会在静止时被加密。   应用程序启动异常:System.Exception:无法解析类型为'Microsoft.AspNetCore.Identity.UserManager 1[[cihanturan.WebUI.Areas.Admin.Models.ApplicationUser, cihanturan.WebUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' for the parameter 'userManager' of method 'Configure' on type 'cihanturan.WebUI.Startup'. ---> System.ArgumentException: Format of the initialization string does not conform to specification starting at index 84. at System.Data.Common.DbConnectionOptions.GetKeyValuePair(String connectionString, Int32 currentPosition, StringBuilder buffer, Boolean useOdbcRules, String& keyname, String& keyvalue) at System.Data.Common.DbConnectionOptions.ParseInternal(Dictionary 2可拆分,字符串连接字符串,布尔值buildChain,字典2 synonyms, Boolean firstKey) at System.Data.Common.DbConnectionOptions..ctor(String connectionString, Dictionary 2同义词,布尔值useOdbcRules的服务)      在System.Data.Common.DbConnectionStringBuilder.set_ConnectionString(字符串值)      在Microsoft.EntityFrameworkCore.MySqlDbContextOptionsExtensions.UseMySql(DbContextOptionsBuilder optionsBuilder,String connectionString,Action 1 mySqlOptionsAction) at cihanturan.WebUI.Startup.<ConfigureServices>b__4_1(DbContextOptionsBuilder options) in C:\Users\Cihan\Documents\Visual Studio 2017\Projects\cihanturan\cihanturan.WebUI\Startup.cs:line 38 at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.DbContextOptionsFactory[TContext](IServiceProvider applicationServiceProvider, Action 2 optionsAction)中      在Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite,ServiceProviderEngineScope范围)      在Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite构造函数CallSite,ServiceProviderEngineScope范围)      在Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite,ServiceProviderEngineScope范围)      在Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite构造函数CallSite,ServiceProviderEngineScope范围)      在Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite,ServiceProviderEngineScope范围)      在Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite构造函数CallSite,ServiceProviderEngineScope范围)      在Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite,ServiceProviderEngineScope范围)      在Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider提供者,类型serviceType)      在Microsoft.AspNetCore.Hosting.Internal.ConfigureBuilder.Invoke(对象实例,IApplicationBuilder构建器)处      ---内部异常堆栈跟踪的结尾---      在Microsoft.AspNetCore.Hosting.Internal.ConfigureBuilder.Invoke(对象实例,IApplicationBuilder构建器)处      在Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder应用)      在Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()   爆击:Microsoft.AspNetCore.Hosting.Internal.WebHost [6]         应用程序启动异常...........

这是Startup.cs

 public class Startup
{
    public Startup(IConfiguration configuration)    
    {
        Configuration = configuration;
    }

    public IConfiguration Configuration { get; }   

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddDbContext<ApplicationDbContext>(options => options.UseMySql(Configuration.GetConnectionString("DbCihanConnection")));
        services.AddDbContext<ApplicationIdentityDbContext>(options => options.UseMySql(Configuration.GetConnectionString("DbCihanConnection")));

        services.AddIdentity<ApplicationUser, IdentityRole>(options =>   
        {  
            options.User.RequireUniqueEmail =true;                               

            options.Password.RequiredLength = 7;
            options.Password.RequireLowercase = false;
            options.Password.RequireUppercase = false;
            options.Password.RequireNonAlphanumeric = false;
            options.Password.RequireDigit = false;

        })
                .AddEntityFrameworkStores<ApplicationIdentityDbContext>()
                .AddDefaultTokenProviders();
        services.ConfigureApplicationCookie(options =>
        {
            options.AccessDeniedPath = "/Admin/Account/AccessDenied";
            options.Cookie.Name = "CookieCihan";
            options.LoginPath = "/Admin/Account/Login";                      

        });

        services.AddMvc()
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
    }
    public void Configure(IApplicationBuilder app, IHostingEnvironment env, UserManager<ApplicationUser> userManager,RoleManager<IdentityRole> roleManager)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }

        app.UseForwardedHeaders(new ForwardedHeadersOptions
        {
            ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
        });
        app.UseStatusCodePagesWithReExecute("/Errors/Index", "?statusCode={0}");   
        app.UseStaticFiles();               
        app.UseAuthentication();   
        app.UseHttpsRedirection();

        app.UseMvc(routes =>
        {
            routes.MapRoute(name: "areas",
                template: "{area:exists}/{controller=Admin}/{action=Index}/{id?}");
        });

        app.UseMvc(routes =>        
        {
            routes.MapRoute(name: "default",
                template: "{controller=Home}/{action=Index}/{id?}");
        });

        MyIdentityDataInitializer.SeedData(userManager, roleManager,app);

    }
}

这是Program.cs

 public class Program
{
    public static void Main(string[] args)
    {
        CreateWebHostBuilder(args).Build().Run();
    }


        public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
            WebHost.CreateDefaultBuilder(args)            
                .UseStartup<Startup>()
                .UseDefaultServiceProvider(options=>options.ValidateScopes=false);
    }

1 个答案:

答案 0 :(得分:-1)

您正在尝试将UserManager注入尚未注册到服务中的Configure Method中。

结果,您的应用程序无法解析UserManager