VB.NET 项目中多个相同命名的资源文件
我希望在我的项目中有多个相同的命名资源文件,所有文件都通过命名空间。以下设置:
Project
- Namespace1 [also a Folder]
- MyResourceFile.resx
- Namespace2.SubNamespace1 [two folders]
- MyResourceFile.resx
通过将资源文件的 Namespace
属性设置为正确的命名空间,可以轻松实现此目的。不幸的是,这将使编译器停止运行:
在“Resources”参数中多次指定了项目 obj\x86\Debug\Project.MyResourceFile.resx。 “资源”参数不支持重复的项目。
看起来,资源文件被编译成一个名为 ProjectNameSpace.Filename.resx
的文件,如果您想在不同的命名空间中拥有多个相同的命名资源文件,这将是一个问题。
有人知道我如何改变这种行为吗?
我想要这个的原因是因为我想将 SQl 语句存储在资源文件中。我的应用程序的数据层隐藏在允许多种实现的接口后面,因此我想到了以下结构:
Project
- ModuleNamespace
- IData.vb
- Datas
- MySQL
- Data.vb (Implementation of IData)
- Queries.resx
- SQLite
- Data.vb
- Queries.resx
- and so on...
我会将这些查询添加到一个简单的类文件中并使用它,但在该项目中我使用的是 VB.NET。 ..这会增加一点痛苦让字符串跨越多行...
Related: What could cause Visual Studio / C# error MSB3105: Duplicate resources
I'd like to have multiple identical named resource files in my project, all separated via the Namespace. The following setup:
Project
- Namespace1 [also a Folder]
- MyResourceFile.resx
- Namespace2.SubNamespace1 [two folders]
- MyResourceFile.resx
This is easily possible by setting Namespace
-property of the resource files to the correct namespaces. Unfortunately this will bring the compiler to a halt:
The item obj\x86\Debug\Project.MyResourceFile.resx was specified more than once in the "Resources" parameter. Duplicate items are not supported by the "Resources" parameter.
As it seems, Resource-Files are compiled into a file called ProjectNameSpace.Filename.resx
, which is a problem if you want to have multiple identical named resource files in different namespaces.
Does somebody know how I can change that behavior?
The reason why I want this is because I want to store SQl-Statements in resource files. The datalayer of my application is hidden behind interfaces which allow multiple implementations, therefor I thought of the following structure:
Project
- ModuleNamespace
- IData.vb
- Datas
- MySQL
- Data.vb (Implementation of IData)
- Queries.resx
- SQLite
- Data.vb
- Queries.resx
- and so on...
I would have added those queries to a simple class-file and used that, but in that Project I'm using VB.NET...which adds a little pain to have a string span multiple lines...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论