【问题标题】:Constructor of language resource file is generated as internal instead of public in WPF语言资源文件的构造函数在 WPF 中生成为内部而不是公共
【发布时间】:2013-01-25 04:36:39
【问题描述】:
namespace PcgTools.PcgToolsResources {
    using System;

   ... some comments
    global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class Strings {

    private static global::System.Resources.ResourceManager resourceMan;

    private static global::System.Globalization.CultureInfo resourceCulture;

    [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
    internal Strings() {
    }

问题是最后一行:

internal Strings() {
}

在运行应用程序时返回 XAML 错误。上面的文件是一个生成的文件(来自strings.resx)。

我现在必须在每个资源文件更改为后更改该行:

public Strings() {
}

有谁知道要改变什么来让它由公共而不是内部自动生成?

【问题讨论】:

  • 当所有属性都是静态的,为什么还需要构造函数?
  • @Palec 不确定……内部 Strings() 行是由框架生成的。我没有尝试删除它(它也是一个旧项目,所以现在我不需要对项目进行任何更改)

标签: c# wpf xaml constructor resources


【解决方案1】:

可能的解决方案是使用自定义代码生成器。见那里:http://www.guysmithferrier.com/post/2008/09/Silverlight-And-Strongly-Typed-Resource-Classes.aspx

【讨论】:

    【解决方案2】:

    How to change Resources.resx template 的副本,其中包含由 Htin Aung 撰写的以下已接受答案


    您可以在资源文件中将 Access Modifier 更改为 Public。

    【讨论】:

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