Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I properly use namespaces in vb.net with embedded resources?

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.

like image 339
Banford Avatar asked Nov 17 '10 11:11

Banford


1 Answers

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.

like image 177
AMissico Avatar answered Oct 23 '22 18:10

AMissico