.NET Development
Error: [$injector:unpr]
Gravatar is a globally recognized avatar based on your email address. Error: [$injector:unpr]
  Mark
  All
  Dec 13, 2024 @ 03:52pm

I am getting this error into the console log

Error: [$injector:unpr] http://errors.angularjs.org/1.4.6/$injector/unpr?p0=localizationServiceProvider%20%3C-%20localizationService%20%3C-%20listController
I/<@http://localhost:5199/LocalizationAdmin/scripts/vendor/angular.min.js:6:416
fb/p.$injector<@http://localhost:5199/LocalizationAdmin/scripts/vendor/angular.min.js:40:409
d@http://localhost:5199/LocalizationAdmin/scripts/vendor/angular.min.js:38:394
fb/t.$injector<@http://localhost:5199/LocalizationAdmin/scripts/vendor/angular.min.js:40:483
d@http://localhost:5199/LocalizationAdmin/scripts/vendor/angular.min.js:38:394
e@http://localhost:5199/LocalizationAdmin/scripts/vendor/angular.min.js:39:161
Ve/this.$get</</<@http://localhost:5199/LocalizationAdmin/scripts/vendor/angular.min.js:80:207
K@http://localhost:5199/LocalizationAdmin/scripts/vendor/angular.min.js:61:190
h@http://localhost:5199/LocalizationAdmin/scripts/vendor/angular.min.js:54:411
Cc/this.$get</W/<@http://localhost:5199/LocalizationAdmin/scripts/vendor/angular.min.js:53:480
yc/d/</<@http://localhost:5199/LocalizationAdmin/scripts/vendor/angular.min.js:20:103
$eval@http://localhost:5199/LocalizationAdmin/scripts/vendor/angular.min.js:132:452
$apply@http://localhost:5199/LocalizationAdmin/scripts/vendor/angular.min.js:133:175
yc/d/<@http://localhost:5199/LocalizationAdmin/scripts/vendor/angular.min.js:20:59
e@http://localhost:5199/LocalizationAdmin/scripts/vendor/angular.min.js:39:193
d@http://localhost:5199/LocalizationAdmin/scripts/vendor/angular.min.js:19:482
yc@http://localhost:5199/LocalizationAdmin/scripts/vendor/angular.min.js:20:274
Xd@http://localhost:5199/LocalizationAdmin/scripts/vendor/angular.min.js:19:83
@http://localhost:5199/LocalizationAdmin/scripts/vendor/angular.min.js:292:240
j@http://localhost:5199/LocalizationAdmin/scripts/vendor/jquery.min.js:2:26911
fireWith@http://localhost:5199/LocalizationAdmin/scripts/vendor/jquery.min.js:2:27724
ready@http://localhost:5199/LocalizationAdmin/scripts/vendor/jquery.min.js:2:29518
I@http://localhost:5199/LocalizationAdmin/scripts/vendor/jquery.min.js:2:29709

My files are in wwwroot/LocalizationAdmin

And this is the DbResourceConfiguration in appsettings.json

"DbResourceConfiguration": {
    "ResourceAccessMode": "DbResourceManager",
    "ConnectionString": "Server=localhost;Database=lubuntu;User Id=sa;Password=Test123#;MultipleActiveResultSets=True;TrustServerCertificate=True;",
    "DataProvider": "SqlServer",
    "ResourceTableName": "localizations",
    "StronglyTypedGlobalResource": "~/Properties/Resources.cs",
    "ResourceBaseNamespace": "AppResources",
    "ResxExportProjectType": "Project",
    "ResxBaseFolder": "~/Properties/",
    "AddMissingResources": false,
    "LocalizationFormWebPath": "~/LocalizationAdmin/"
  },

And in the program.cs

public static void RegisterLocalization(this IServiceCollection services, WebApplicationBuilder builder)
    {
        // Add standard localization services
        services.AddLocalization(options => { options.ResourcesPath = "Properties"; });

        // Replace StringLocalizers with Db Resource Implementation
        services.AddSingleton(typeof(IStringLocalizerFactory), typeof(DbResStringLocalizerFactory));
        services.AddSingleton(typeof(IHtmlLocalizerFactory), typeof(DbResHtmlLocalizerFactory));

        // Bind DbResourceConfiguration from appsettings.json
        var dbResourceConfig = new DbResourceConfiguration();
        builder.Configuration.GetSection("DbResourceConfiguration").Bind(dbResourceConfig);

        // Required: Enable Westwind.Globalization with bound configuration
        services.AddWestwindGlobalization(opt =>
        {
            // Use values from DbResourceConfiguration
            opt.ResourceAccessMode = dbResourceConfig.ResourceAccessMode;
            opt.ConnectionString = dbResourceConfig.ConnectionString;
            opt.DataProvider = dbResourceConfig.DataProvider;
            opt.ResourceTableName = dbResourceConfig.ResourceTableName;
            opt.AddMissingResources = dbResourceConfig.AddMissingResources;
            opt.ResxBaseFolder = dbResourceConfig.ResxBaseFolder;

            opt.ConfigureAuthorizeLocalizationAdministration(actionContext =>
            {
                return true;
            });
        });


        // Define supported cultures
        CultureInfo[] supportedCultures = new[]
        {
            new CultureInfo(Constants.CultureEn),
            new CultureInfo(Constants.CultureTr)
        };

        CultureInfo[] supportedUiCultures = supportedCultures;

        // Configure request localization options
        builder.Services.Configure<RequestLocalizationOptions>(options =>
        {
            options.DefaultRequestCulture = new RequestCulture(Constants.CultureEn, Constants.CultureEn);
            options.SupportedCultures = supportedCultures;
            options.SupportedUICultures = supportedUiCultures;
            options.RequestCultureProviders = new List<IRequestCultureProvider>
            {
                new CookieRequestCultureProvider()
            };
        });
    }

How I can fix this?

© 1996-2025