2
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?

Michel Keijzers
  • 15,025
  • 28
  • 93
  • 119
  • 1
    When all the properties are static, why do you need the constructor? – Palec Nov 12 '19 at 18:24
  • @Palec Not sure … the internal Strings() line is generated by the framework. I haven't tried to remove it (also it's an old project, so for now I don't need to make any changes to the project anymore) – Michel Keijzers Nov 13 '19 at 15:30

2 Answers2

3

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

Memoizer
  • 2,231
  • 1
  • 14
  • 14
0

Duplicate of How to change Resources.resx template which has the following accepted answer written by Htin Aung


enter image description here

You can change Access Modifier to Public in resource file.

thelem
  • 2,642
  • 1
  • 24
  • 34
  • This does not fix the issue. It makes the class public, but the constructor remains internal, meaning it cant be accessed from other dlls. Only fix I've been able to find for this that allows it to be accessed from other assemblies is to add a custom AssemblyInfo.cs to your assembly, turn off auto generated assembly info by editing csproj file manually, and adding an attribute to the AssemblyInfo.cs to provide internal access to the desired class. See https://stackoverflow.com/a/42183749/2001934 and https://stackoverflow.com/a/47075759/2001934 and https://stackoverflow.com/a/1199612/2001934. – Breeno Apr 26 '19 at 12:48