【问题标题】:Asp.net Core 2.0 View Localization ErrorAsp.net Core 2.0 查看本地化错误
【发布时间】:2017-11-23 08:38:05
【问题描述】:

您好尝试在 .net core 2.0 中进行本地化 我关注了这篇文章 https://docs.microsoft.com/en-us/aspnet/core/fundamentals/localization 视觉工作室 2017 视窗 10

在Resources中添加这些文件(用于视图索引)并编译后

See Resource Files I Added

我在构建时遇到了他的错误

Severity    Code    Description Project File    Line    Suppression State
Error   CS0579  Duplicate 'global::System.CodeDom.Compiler.GeneratedCodeAttribute' attribute    Mnp E:\Websites\Developing\Mnp\Mnp\BudgetT\Resources\Views\Home\Index.en-US.Designer.cs 22  Active
Error   CS0579  Duplicate 'global::System.Diagnostics.DebuggerNonUserCodeAttribute' attribute   Mnp E:\Websites\Developing\Mnp\Mnp\BudgetT\Resources\Views\Home\Index.en-US.Designer.cs 23  Active
Error   CS0579  Duplicate 'global::System.Runtime.CompilerServices.CompilerGeneratedAttribute' attribute    Mnp E:\Websites\Developing\Mnp\Mnp\BudgetT\Resources\Views\Home\Index.en-US.Designer.cs 24  Active
Error   CS0101  The namespace 'Mnp.Resources.Views.Home' already contains a definition for 'Index'  Mnp E:\Websites\Developing\Mnp\Mnp\BudgetT\Resources\Views\Home\Index.en-US.Designer.cs 25  Active
Error   CS0111  Type 'Index' already defines a member called '.ctor' with the same parameter types  Mnp E:\Websites\Developing\Mnp\Mnp\BudgetT\Resources\Views\Home\Index.en-US.Designer.cs 32  Active
Error   CS0579  Duplicate 'global::System.CodeDom.Compiler.GeneratedCodeAttribute' attribute    Mnp E:\Websites\Developing\Mnp\Mnp\BudgetT\Resources\Views\Home\Index.en.Designer.cs    22  Active
Error   CS0579  Duplicate 'global::System.Diagnostics.DebuggerNonUserCodeAttribute' attribute   Mnp E:\Websites\Developing\Mnp\Mnp\BudgetT\Resources\Views\Home\Index.en.Designer.cs    23  Active
Error   CS0579  Duplicate 'global::System.Runtime.CompilerServices.CompilerGeneratedAttribute' attribute    Mnp E:\Websites\Developing\Mnp\Mnp\BudgetT\Resources\Views\Home\Index.en.Designer.cs    24  Active

See the Duplicate Error

我添加的文件有错吗?

【问题讨论】:

    标签: .net asp.net-core


    【解决方案1】:

    对于 ASP.NET Core 本地化,您不需要 .Designer.cs 文件。

    对于每个资源文件,在解决方案资源管理器中选择文件,然后按 F4 查看其属性。选择指定为“自定义工具”的值并将其删除。

    “自定义工具”字段应为空。

    即使您确实需要自定义工具生成的代码,也只需要其中一个文件(通常是中性语言 .resx 文件)。

    在你的屏幕截图中,我可以看到你有文件:

    • Index.en.Designer.cs
    • Index.en-IN.Designer.cs
    • Index.en-US.Designer.cs

    这三个文件会包含重复的代码,导致编译错误。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-23
      • 1970-01-01
      • 2017-01-06
      • 1970-01-01
      • 2017-04-11
      • 2016-10-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多