Visual Studio VB - Having to include the project name in "Import myNamespace" declarations

I am using namespaces for the first time in a Visual Studio project, following a sample project tutorial and am struggling to use them.
(I usually don't bother specifying namespaces but am trying to do things "by the book"!)

My basic problem is that Visual Studio's intellisense doesn't like me doing a VB Imports statement with just the namespace I specify - it wants me to add the project name to the namespace to validate my code.  When I do this, my code can build successfully but I then get problems further down the line. Before getting to solving these latter problems, I'd like to understand why this namespace/imports behaviour is different behaviour to that of the sample code I'm trying to emulate.

The sample project that I am working with is:
The complication is that I'm using Visual Studio 2017 and I'm translating all of the code to VB as I go!

In my code, I am specifying a Namespace in a vb file as:
Namespace WingtipToys.Models

    Public Class Product

    End Class

End Namespace

Open in new window

...but when I want to use it in an Imports statement on codebehind for another page, intellisense is insisting that I include the project name (also "WingtipToys")
Intellisense not happy with my code without adding the extra namespace.Intellisense suggests I change it to
Imports WingtipToys.WingtipToys.Models.Product

Open in new window

In the sample project code I am working to, the shorter imports statement works just fine - intellisense quite happy with it - project builds - no errors while debugging.

In my project though:
If I stick to the shorter Imports statement, my code won't build successfully.
If I use the longer namespace declaration in the Imports statement my code builds but fails elsewhere during debug.
I just can't work out why they are being handled differently.  Do I have to "declare" the namespaces somewhere globally?

Also, the way Visual Studio displays my code and the sample code differs very slightly:
My VB code:
My code
The sample C# code that I am trying to emulate (note the difference in how Visual Studio displays the class)
The sample code I am trying to emulate
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BeamsonAuthor Commented:
Minor update:
The knock-on problems that I was experiencing can be remedied by changing various references in the code which used the shorter namespace to the longer one.  I'd still just like to know why I need the extra word in the namespace to make my version of the code to work.

Adding the extra "WingtipToys." word to the ItemType below gets around my problem but I still don't understand why I need to do that to make things work.
 <asp:ListView ID="productList" runat="server" 
                DataKeyNames="ProductID" GroupItemCount="4"
                ItemType="WingtipToys.Wingtiptoys.Models.Product" SelectMethod="GetProducts">

Open in new window

Paul JacksonSoftware EngineerCommented:
In the default root Namespace is the same as your project file, and can be inspected in the Project properties Application section.
This means you don't have to specify a namespace in each file as they automatically belong to the root namespace.
If you want to add a sub-namespace you can and it will be automatically added as part of the root namespace so specifying in your file:

Namespace Models

will then be referenced by WingtipToys.Models, as WingtipToys is the root namespace

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BeamsonAuthor Commented:
Easy when you know how!

So in VB.NET, rather than rewrite all my Imports codes, or class references to add the extra namespace tag, I remove the root namespace from my classes and it all magically works.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.