Assign a namespace to a resource file in a Visual Basic project.

D

Dick

Please can you tell me how to assign a namespace to a resource file in a
Visual Basic project?

In C# such resources file inherit their namespace based upon the folder
hierarchy in which they are stored but in Visual Basic all such resources
appear in the project's default namespace. This is fine when there are just a
few resources but becomes cumbersome when there are lots.
 
Z

Zhi-Xin Ye [MSFT]

Hi Dick,

Thank you for using Microsoft Managed Newsgroup Service, my name is Zhi-Xin
Ye, I'm assigned to help you on this issue.

From your description, you mean VB.NET, right? If misunderstand you, please
let me know.

For VB.NET, it's a by design feature that all the global resource files
will be assigned to My.Resources namespace. However, you can name the
resources files in a manner that they're not corruptted.

For example, you can create a file structure like this:

--Resources
- Res1
+ Res1_Resource1.resx
+ Res1_Resource2.resx
+ Res1_Resource3.resx
- Res2
+ Res2_Resource1.resx
+ Res2_Resource2.resx
- Res3
+ Res3_Resource1.resx
+ Res3_Resource2.resx
+ Res3_Resource3.resx

If you have any problems or concerns, please feel free to let me know.

Sincerely,
Zhi-Xin Ye
Microsoft Managed Newsgroup Support Team

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can

improve the support we provide to you. Please feel free to let my manager
know what you think of the level

of service provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to

http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the

community or a Microsoft Support Engineer within 2 business day is
acceptable. Please note that each follow

up response may take approximately 2 business days as the support
professional working with you may need

further investigation to reach the most efficient resolution. The offering
is not appropriate for situations

that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working

with a dedicated Microsoft Support Engineer by contacting Microsoft
Customer Support Services (CSS) at

http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

Dick

OK, by "design feature" I guess you mean "design flaw". I bet if I suggested
you dropped class namespaces and named all your classes in such a way you'd
think I was mad. In any case, you've answered my question and I'll therefore
stop looking for a way to do it, so thanks for that. Cheers.
 
H

Herfried K. Wagner [MVP]

Dick said:
OK, by "design feature" I guess you mean "design flaw". I bet if I
suggested
you dropped class namespaces and named all your classes in such a way
you'd
think I was mad. In any case, you've answered my question and I'll
therefore
stop looking for a way to do it, so thanks for that.

In VB the namespace a resource file belongs to fortunately isn't tied to the
physical folder structure. Instead, you can specify the target namespace by
selecting the resource file and assigning the desired target namespace to
its "Namespace of the user-defined tool" (translated from the German version
of VS 2008) property in the properties window.
 
Z

Zhi-Xin Ye [MSFT]

Hi Dick,

I'm sorry for the misleading.
Herfried is right. You can change the "Custom Tool Namespace" property for
the resource file to change its namespace.

Sincerely,
Zhi-Xin Ye
Microsoft Managed Newsgroup Support Team

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can

improve the support we provide to you. Please feel free to let my manager
know what you think of the level

of service provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

Dick

Yup agreed, you can set this property, and of course I looked at this right
at the beginning of my research, but unless I'm mistaken, this doesn't apply
a namespace to the resource. Instead it simply saves a namespace to be used
later by a custom tool, but I don't think the compiler is a custom tool and
hence doesn't use the it. Perhaps you could demonstate it being used?
 
H

Herfried K. Wagner [MVP]

Dick said:
Yup agreed, you can set this property, and of course I looked at this
right
at the beginning of my research, but unless I'm mistaken, this doesn't
apply
a namespace to the resource. Instead it simply saves a namespace to be
used
later by a custom tool, but I don't think the compiler is a custom tool
and
hence doesn't use the it. Perhaps you could demonstate it being used?

I have tested it here in VS 2008 and it works automatically. Just take a
look at the namespaces and classes in object browser. The program
transforming the ResX files will emit the desired namespace based on the
property's value.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top