name space in vb.net using visual studio?

Posted on 2012-08-21
Medium Priority
Last Modified: 2012-08-31

I have both vs2008 and vs2010.

I have an application called Maxx with several projects named as
GUI, DAL, ConfigManager
I would like to have name spaces like this.
Maxx.GUI, MaxxDAL, Maxx.ConfigManager.

With C#, I do this in the properties of the VS projects.
I change the Assembly name and Default namespace.

It seems that it is a little different in VB.net.

Can you help?

I would like to have a solution name, Maxx with several VB project named:
Maxx.GUI, MaxxDAL, Maxx.ConfigManager.

Also when I create a .vb page in each of those projects, I want the VS to add the namespace.
Question by:dkim18
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 668 total points
ID: 38316655
The "Default Namespace" ("Root namespace" in VB) is simply the namespace that is applied whenever you add a new item--it has no bearing on existing items. To change existing items you will have to manually open up each file and make the change (a find/replace should work as well). In Solution Explorer, you can single-click a highlighted project, or right-click the project and select "Rename" to change the name as you like.

Author Comment

ID: 38316754
It seems that with c# project, it automatically added the namespace in the code.
But in vb.net, it doesn't seem that way. Is that right?
LVL 83

Expert Comment

ID: 38316853
VB.NET applies the root namespace to each file and class automatically

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

LVL 40

Assisted Solution

by:Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger) earned 664 total points
ID: 38318855
In VB, simply open the Project properties (Project menu).

In the Application tab, define the Root namespace such as Maxx.GUI. This becomes the namespace for the assembly (.exe or .dll).

If you want, you can even create "sub-namespaces", many namespaces inside a given project. Simply enclose all the code of the class in a Namespace structure:

Namespace Components
    Class YourClass

    End Class
End Namespace

The root namespace and the Namespace clause are appended together so that the namespace for your classe becomes Maxx.GUI.Components.YourClass

Author Comment

ID: 38320274

Thanks for that link.
That's what I was confusing about.

So in VB.net, I should not explicitly put namespace.
LVL 83

Accepted Solution

CodeCruiser earned 668 total points
ID: 38321297
Unless you are creating additional namespaces. If you do not need any name space (single exe etc) then you don't need to specify it in code. If you want spaces like MyProject.DAL and MyProject.Presentation etc then you specify MyProject as root namespace (which it is by default) and add

Namespace DAL
NameSpace Presentation

in code files.

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question