如何在带有嵌入资源的 vb.net 中正确使用命名空间?

发布于 2024-10-03 06:50:46 字数 537 浏览 1 评论 0原文

我在 VB.Net winforms 项目中将一些 Crystal Reports 组织成更易于管理的结构时遇到问题。

这些报告都默认为根命名空间(在本例中为“Reports”),然后具有“analysisKS3SubjectSummary.rpt”、“analysisKS4SubjectSummary.rpt”等名称。

为了整理这一点,我为报告类设置了命名空间,并在报告的“自定义工具命名空间”属性。它们的结构如下:

Reports.Analysis.KS3.SubjectSummary
Reports.Analysis.KS4.SubjectSummary

命名空间工作正常,但如果报告具有与上面相同的名称。该项目将无法构建,表明两个嵌入资源不能具有相同的名称。

然后它显示“Reports.SubjectSummary”作为错误描述,但没有此类资源。看起来它试图在构建过程中将它们放回根命名空间。

知道如何强制嵌入式资源使用为其提供的正确名称空间吗?

PS 显然这可以在 C# 中运行,无需修改。但我需要它与 VB 一起工作。

I'm having trouble organizing some Crystal Reports into a more manageable structure in a VB.Net winforms project.

The reports were all defaulting to the root namespace (in this case 'Reports') and then having names like 'analysisKS3SubjectSummary.rpt', 'analysisKS4SubjectSummary.rpt' etc.

To tidy this up I set namespaces for the report classes, and on the 'Custom Tool Namespace' property of the report. These are structured like so:

Reports.Analysis.KS3.SubjectSummary
Reports.Analysis.KS4.SubjectSummary

The namespaces worked fine, but if a report has the same name like above. The project will not build, stating that two embedded resources cannot have the same name.

It then displays 'Reports.SubjectSummary' as the error description, but there is no such resource. It looks like its trying to put them back to the root namespace during build.

Any idea how I can force the embedded resources to use the proper namespaces given to them?

P.S. Apparently this works in C# with no modification required. But I need it to work with VB.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

许仙没带伞 2024-10-10 06:50:46

既然您提到这适用于 C#,那么我怀疑该项目的“根命名空间”正在影响您的“自定义工具命名空间”。

自定义工具命名空间“附加”到项目的根命名空间。您可能没有考虑到这一点。当我怀疑命名空间问题或命名空间构建错误时,我通常会转向“对象浏览器”。

打开“对象浏览器”并检查项目的命名空间。希望命名空间问题是显而易见的。

如果项目的根命名空间是“Reports”并且自定义工具命名空间是“Reports.Analysis.KS4.SubjectSummary”,则完整命名空间是“Reports.Reports.Analysis.KS4.SubjectSummary”。 C# 项目没有根命名空间。他们有一个不一样的“默认命名空间”。

要解决此问题,请将自定义工具命名空间更改为“Analysis.KS4.SubjectSummary”或清除项目的根命名空间。我建议更改自定义工具命名空间。

Since you mentioned this works for C#, then I suspect that the project's "Root namespace" is affecting your "Custom Tool Namespace".

The custom tool namespace is "appended" to the project's root namespace. You may not be taking this into account. I usually turn to the "Object Browser" when I suspect namespace issues or have namespace build errors.

Open the "Object Browser" and check out your project's namespaces. Hopefully, the namespace issue is obvious.

If the project's root namespace is "Reports" and your custom tool namespace is "Reports.Analysis.KS4.SubjectSummary" then the full namespace is "Reports.Reports.Analysis.KS4.SubjectSummary". C# projects do not have a root namespace. They have a "Default namespace" which is not the same.

To resolve this, change your custom tool namespace to "Analysis.KS4.SubjectSummary" or clear the project's root namespace. I suggest changing the custom tool namespace.

溇涏 2024-10-10 06:50:46

同意 AMissico 的观点,我总是从 VB.NET 项目属性中清除根名称空间,并在代码中显式处理它。

Agreed with AMissico, I always clear the root name space from the VB.NET project properties and handle it in code explicitly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文