【发布时间】:2019-12-11 13:41:53
【问题描述】:
这是我在代码中添加的导致我遇到此错误的内容:
我正在使用 VSCode。
在 StartUp.cs - ConfigureServices 中
services.AddLocalization (options => options.ResourcesPath = "Resources");
services.AddMvc ().SetCompatibilityVersion (Microsoft.AspNetCore.Mvc.CompatibilityVersion.Version_2_1)
.AddViewLocalization (LanguageViewLocationExpanderFormat.Suffix, opts => { opts.ResourcesPath = "Resources"; });
在 StartUp.cs - 配置
var localizationOptions = new RequestLocalizationOptions
{
DefaultRequestCulture = new RequestCulture("en-US"),
SupportedCultures = supportedCultures,
SupportedUICultures = supportedCultures
};
localizationOptions.RequestCultureProviders.Clear();
localizationOptions.RequestCultureProviders.Add(new QueryStringRequestCultureProvider());
app.UseRequestLocalization(localizationOptions);
我在这个文件夹中创建了资源文件:
资源
观看次数
赠款
Index.en-US.resx
Index.hu-HU.resx
并调用此视图中的值:
查看
赠款
Index.cshtml
问题:
我在构建项目时,在 xxx.Resources.cs 文件中新创建的 OBJ 文件夹出现错误,“可执行文件不能是附属程序集;区域性应始终为空”
对象
调试
netcoreapp2.2
zh-CN
xxx.resources.cs
xxx.resources.dll
[assembly: System.Reflection.AssemblyCultureAttribute("en-US")]
该项目将运行,但此行会给您一个错误并且不会被识别。
我想做的是在每次构建项目时完全消除这个错误。
我也认为这可能是一个智能感知错误。
【问题讨论】:
标签: asp.net-core localization .net-assembly cultureinfo