I have been generating a StronglyTypedClass file using resgen.exe in my Windows Form application using C# and .NET 4.5

According to syntax I can make the StringResources class as public but the Constructor still remains internal.

resgen inputFilename [outputFilename] /str:language[,namespace,[classname[,filename]]] [/publicClass]

When I put this argument [/publicClass], it just makes the class as public but the constructor is still internal.

internal StringResources() {}

Please suggest, how to achieve this.

1

There are 1 answers

2
Mike Fuchs On

Very likely your teammate wanted to have that constructor public because he wants to use the resources in xaml.

Just create a class in the same assembly, which inherits the resources file and exposes a public constructor, then use this class instead.

public class ResourcesProxy : Properties.Resources
{
    /// <summary>
    /// resolves the problem of internal constructor in resources.designer.cs
    /// in conjunction with xaml usage
    /// </summary>
    public ResourcesProxy() : base()
    {
    }
}