Visual-studio – Namespace browsing works correctly in tools and as Imports but not in code window (except imports line)

intellisensenamespacesvisual studio

I posted this question and still have not gotten an answer so I thought I would link to the following video file of the problem…sorry I tried to upload the video to videos.yahoo.com but the downgraded video is unviewable. So here is a direct link to the avi file hosted on my website.

SUMMARY OF THE PROBLEM
I have a controls project…GoodMins.MeetingMgr.Winforms.Controls.
It has a project reference to GoodMins.MeetingMgr.BizObjects.
In ANY code file of GoodMins.MeetingMgr.Winforms.Control I can
*Add an Imports to GoodMins.MeetingMgr.BizObjects and intellisense browses the namespace path successfully.
*IN THE SAME file Inside the CLASS Declaration I can no longer browse successfully the GoodMins.MeetingMgr.BizObjects namespace.
*But I CAN browse MeetingMgr.BizObjects (which should be an invalid namespace). It does not find thee root GoodMins namespace.

The problem is that when I make a change to the file in the designer…visual studio re-generates the code behind in the designer file and uses the correct namespace. But compile errors occur because Visual Studio does not recognize that namespace.

HELP… I have spent about 3 hours on this tonight to no avail.

THE OLD QUESTION WITH MORE DETAILS.

THE PROBLEM

I have just noticed something strange in my project which is causing some compile time issues. If you want to get to the bottom line question read the bold text at the bottom of the question. Read it all for all of the behavior details.

I have controls project and in that project I am referencing another bizobjects project.

I use the data source view of my control project to create objects to drop onto the controls and it creates the AttendeesBindingSource. And all of that works fine.

At compile time though I am getting an error in the DESIGNER file of the control:

Me.AttendessBindingSource.DataSource = GetType(GoodMins.MeetingMgr.BizObjects.Attendees)

This has the little squiggley line under GoodMins.MeetingMgr.BizObjects.Attendees with the warning "Type 'GoodMins.MeetingMgr.BizObjects.Attendees' is not defined"

A LITTLE MORE INFORMATION
I have figured out how to solve the error.

I simply remove GoodMins. from the reference. In other words…to VS I can change the above line from

Me.AttendessBindingSource.DataSource = GetType(GoodMins.MeetingMgr.BizObjects.Attendees)

to

Me.AttendessBindingSource.DataSource = GetType(MeetingMgr.BizObjects.Attendees)

and I can compile. When I make a little change to the control reverts the code and I can't compile again.

FYI the Data Source View window Is showing the full namespace of GoodMins.MeetingMgr.BizObjects as the parent I am trying to add

FYI If I try to add an Imports statement (This is a vb.net project) Intellisense will not find the project GoodMins.MeetingMgr.BizObjects. But it WILL find the project MeetingMgr.BizObjects.

FYI the Object Browser, when in "View Namespaces" mode, shows the GoodMins.MeetingMgr.BizObjects namespace and does NOT show the MeetingMgr.BizObjects namespace.

One last piece of information. The way I did namespacing in the BizObject project is by removing the namespace declaration from the project properties and putting an explicit namespace declaration around each class file as "Namespace GoodMins.MeetingMgr.BizObjects" … "End Namespace" I regret doing that and I may change it someday but for now I am stuck with it.

So here is the bottom line to my question…Why do all of the tools built into visual studio want to use the full namespace of GoodMins.MeetingMrg.BizObjects but intellisense in the code window does not recognize the full namespace but will recognize a truncated namespace of MeetingMgr.BizObjects.

I have looked everywhere I know to look and can't figure this one out.

Seth

Best Answer

Defining namespaces in VB is a little odd. Everything is automatically a part of the default namespace (defined in the project properties). When you add namespace statements, you don't add the default namespace like you would in C#.

For example, if your default namespace is GoodMins then,

 Namespace MeetingMgr
 End Namespace

would actually be translated as GoodMins.MeetingMgr. If you define the namespace as

 Namespace GoodMins.MeetingMgr
 End Namespace

then that would be the same as GoodMins.GoodMins.MeetingMgr.