abp icon indicating copy to clipboard operation
abp copied to clipboard

SettingDefinitionProviders Not Getting Loaded

Open wayneboyles opened this issue 7 years ago • 1 comments

This may be a mistake I'm making as I don't know the framework well enough yet but I have a very simple ASP.NET Core MVC application. I've referenced 'Volo.Abp.AspNetCore.Mvc' and my web module has the [DependsOn(typeof(AbpAspNetCoreMvcModule))] attribute.

My module is setup as follows for testing purposes:

public override void PreConfigureServices(ServiceConfigurationContext context)
{
     context.Services.PreConfigure<AbpMvcDataAnnotationsLocalizationOptions>(options =>
     {
          options.AddAssemblyResource(typeof(BasicMvcTestResource));
     });
}

public override void ConfigureServices(ServiceConfigurationContext context)
{
     var env = context.Services.GetHostingEnvironment();
     var config = context.Services.GetConfiguration();

     Configure<VirtualFileSystemOptions>(options =>
     {
          options.FileSets.AddEmbedded<BasicMvcTestResource>();
     });

     Configure<AbpLocalizationOptions>(options =>
     {
          options.Resources
		.Add<BasicMvcTestResource>()
		.AddBaseTypes(typeof(AbpValidationResource))
		.AddVirtualJson("/Localization/BasicMvcTest");

          options.Languages.Add(new LanguageInfo("en", "en", "English"));
     });

     Configure<AbpAspNetCoreMvcOptions>(options =>
     {
          options.ConventionalControllers.Create(typeof(ApplicationModule).Assembly);
     });
}

public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
     var app = context.GetApplicationBuilder();
     var env = context.GetEnvironment();

     if (env.IsDevelopment())
     {
          app.UseDeveloperExceptionPage();
          app.UseDatabaseErrorPage();
     }
     else
     {
          app.UseStatusCodePagesWithRedirects("~/Error?httpStatusCode={0}");
          app.UseExceptionHandler("/Error");
     }

     app.UseVirtualFiles();

     // This line throws the Exception: Setting Not Found: DefaultLanguage
     app.UseAbpRequestLocalization();

     app.Run(async (ctx) =>
     {
          await ctx.Response.WriteAsync("Hello World!");
     });
}

I'm just trying to use the Localization module of the Framework right now for testing but can't get passed this issue. As I said I don't know the ins and outs of the framework yet but from stepping through the code it doesn't look like any of the SettingDefinitionProviders are getting loaded automatically.

Am I missing something or should I be able to use the Volo.Abp.Localization module without first loading / configuring another module?

Interestingly, if you download a project template from the ABP website and run it, it works just fine... the biggest difference that I can tell between my test project and the template is its loading the ASP.NET MVC Core ABP modules... could they be registering the DefinitionProviders?

wayneboyles avatar May 08 '19 19:05 wayneboyles

hi @wayneboyles

Most of the time you should refer to the template project and documentation, follow its conventions and coding styles.

Can you share your project source code?

maliming avatar May 09 '19 03:05 maliming