简体   繁体   English

如何在使用Resgen.exe和C#和.NET 4.5生成的StronglyTypedClass文件中将构造方法StringResources公开

[英]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.

相关问题 重定向输出时ResGen.exe卡住了 - ResGen.exe stucks when redirect output 使用.NET 4.5 C#创建一个.exe文件,然后在c#中向其中写入代码,然后将其打开 - Using .NET 4.5 C# to create a .exe file then write code to it in c# then open it .NET 3.5生成的exe文件无法加载使用.NET 4.5创建的dll? - exe file generated using .NET 3.5 cannot load dll created using .NET 4.5? 如何使用C#.NET 4.5将文件从ZIP存档读取到内存而不首先将其解压缩到文件中? - How to read file from ZIP archive to memory without extracting it to file first, by using C# .NET 4.5? 如何制作 c# 控制台 app.exe 以打开保存对话框以保存应用程序生成的文件? - How to make a c# console app .exe to open a save dialog to save a file generated by the app? C#、. NET 4.5:XMLSerializer构造函数重载(“位置”)上的无法解释的参数 - C#, .NET 4.5: Unexplained parameter on XMLSerializer constructor overload (“location”) C# 生成的 RSA 公钥是一个 XML 文件。 PHP中的公钥如何解密或转换? - The RSA public key generated by C# is an XML file. How can the public key be decrypted or converted in PHP? 如何从 c# 程序集和 dll 制作单个 exe 文件? - How to make a Single exe file from c# assembly and dll? C#.net4.5解包Zip文件 - C# .net4.5 Unpack Zip file 使用TextWriter.Synchronized或在多线程文件IO中锁定 - C#WPF .net 4.5 - Using TextWriter.Synchronized or having lock in multithreaded file IO - C# WPF .net 4.5
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM