删除程序集中的默认语言并将其移至附属程序集
我有一个主要用 C# 编写的 .Net 3.5 应用程序,它使用 .resx 文件来存储几种不同语言的国际化数据,包括字符串、控件大小和位置等。我想弄清楚的是:是否可以以与其他文化数据大致相同的方式将默认文化数据拉出到卫星程序集中的方式编译我的应用程序?
我试图防止用户以一种(非默认)语言使用该软件,删除 bin 目录中的区域性文件夹,然后访问默认语言的情况。
如果由于框架限制这是不切实际或不可能的,是否可以使用默认语言以外的语言进行编译,以便我可以向用户提供应用程序的单个非默认版本?
非常感谢您的回答。
I have a .Net 3.5 application written mostly in C# that uses .resx files to store internationalization data for several different languages, consisting of strings, control sizes and positions, etc. What I'm trying to figure out is this: it is possible to compile my application in such a way that the default culture data will be pulled out into a satellite assembly in much the same way as the other culture data?
I'm trying to prevent a situation where the user uses the software in one (non-default) language, removes the culture folder in the bin directory, and then has access to the default language.
If this is impractical or impossible due to framework limitations, is it possible to perhaps compile in a language other than the default, so that I could give a single, non-default version of the application to the user?
Thanks so much for your answers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
几天前我做了类似的事情,因为我需要所有应用程序的程序集都可以访问相同的资源。您只需创建一个包含资源的单独程序集,并从应用程序的程序集中引用它。请注意,如果您这样做,资源程序集将不会是卫星程序集:它将从其他程序集显式引用,并且如果它不存在,应用程序将根本不会启动。
另请注意,默认情况下 Visual Studio 生成的资源类是内部的。要使其公开,您需要将自定义工具
ResxFileCodeGenerator
替换为PublicResxFileCodeGenerator
。I did something similar just a few days ago, because I needed all my app's assemblies to have access to the same resources. You just need to create a separate assembly containing the resources, and reference it from your app's assemblies. Note that if you do that, the resource assembly won't be a satellite assembly: it willbe explicitly referenced from other assemblies, and the app won't start at all if it's not present.
Also note that by default the resources classes generated by Visual Studio are internal. To make them public, you need to replace the custom tool
ResxFileCodeGenerator
withPublicResxFileCodeGenerator
.