Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Constructor StringResources to public in StronglyTypedClass file generated using resgen.exe with C# and .NET 4.5

Tags:

c#

.net

resgen

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.

like image 357
Indigo Avatar asked Dec 21 '25 02:12

Indigo


1 Answers

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()
    {
    }
}
like image 50
Mike Fuchs Avatar answered Dec 22 '25 15:12

Mike Fuchs



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!