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:
Public Class Product
...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 suggests I change it to
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:
The sample C# code that I am trying to emulate (note the difference in how Visual Studio displays the class)