Search code examples
c#wpfxamlconstructorresources

Constructor of language resource file is generated as internal instead of public in WPF


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() {
    }

The problem is that the last line:

internal Strings() {
}

returns a XAML error when running the application. The file above is a generated file (from strings.resx).

I now have to change the line after every resource file change into:

public Strings() {
}

Does anybody know what to change to have it generated by public instead of internal automatically?


Solution

  • Possible solution is to use custom code generator. See there: http://www.guysmithferrier.com/post/2008/09/Silverlight-And-Strongly-Typed-Resource-Classes.aspx