So I built a class library that I will use for various different projects in the future. Now when I want to implement it and set the options in my Program.cs file, my blazor app gets stuck on the Loading... page. I can't seem to find the problem or why this is occuring.
In my class library I have a model ConfigurationSettings and a class with a method to set the configuration settings.
public class ConfigurationSettings
{
public string ConnectionString { get; set; }
public string Token { get; set; }
public string Issuer { get; set; }
public string Audience { get; set; }
}
public static class ServiceCollectionExtensions
{
public static IServiceCollection AddLibrary(this IServiceCollection services, Action<ConfigurationSettings> configure)
{
services.Configure(configure);
services.AddDbContext<ApplicationDbContext>((provider, options) =>
{
var myLibraryOptions = provider.GetRequiredService<IOptions<ConfigurationSettings>>().Value;
options.UseSqlServer(myLibraryOptions.ConnectionString);
});
return services;
}
}
This configurationSettings will come from the main application implementing this class library.
In my Blazor Web Assembly application, I added the following to set the configurationSettings->
builder.Services.AddLibrary(options =>
{
options.ConnectionString = connectionString;
IConfigurationSection configurationSettingsSection = builder.Configuration.GetSection("ConfigurationSettings");
options.Token = configurationSettingsSection["Token"];
options.Issuer = configurationSettingsSection["Issuer"];
options.Audience = configurationSettingsSection["Audience"];
});
builder.Services.AddScoped<IAuthService, AuthService>();
Any suggestions on what I can possibly do to test and solve this issue as when I remove the above from my Program.cs everything works without issues.
So the error I later found was Uncaught SyntaxError: import.meta may only appear in a module
To solve this issue, I updated my visual studio, and all the nuget packages. It resolved the issue.