[英]How to make Constructor StringResources to public in StronglyTypedClass file generated using resgen.exe with C# and .NET 4.5
I have been generating a StronglyTypedClass file using resgen.exe in my Windows Form application using C# and .NET 4.5 我一直在使用C#和.NET 4.5在Windows窗体应用程序中使用resgen.exe生成StronglyTypedClass文件。
According to syntax I can make the StringResources class as public but the Constructor still remains internal. 根据语法,我可以将StringResources类设置为公共类,但构造方法仍保留在内部。
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. 当我使用此参数[/ publicClass]时,它只是使该类成为公共类,但构造函数仍在内部。
internal StringResources() {}
Please suggest, how to achieve this. 请提出建议,如何实现这一目标。
Very likely your teammate wanted to have that constructor public because he wants to use the resources in xaml. 您的队友很可能希望将该构造函数公开,因为他想使用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()
{
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.