Getting references and namespaces right is critically important when programming in VB.NET. It used to be easier in the old VB6. As an example, here's the Microsoft SOAP (Simple Object Access Protocol) library in the VB6 Object Browser:
Click Here to display the illustration
Skilled VB6 programmers have complained that the VB.NET tools for handling references are not what they should be.
"I've encountered a reference to the Namespace "VB6", except I can't find the Namespace "VB6" by searching the Object Browser. Anyone have any hints on finding Namespace "VB6"?
The other reader helpfully added, "The full path of the namespace is Microsoft.VisualBasic.Compatibility.VB6. However, when I tried to include this namespace in a project, I was unable to locate it. I'm not sure why. I have VS 2005 professional installed, so I would expect it to be there. That doesn't make too much sense to me."
By the end of the thread in the About VB Forum, one of my friends was saying that .NET must have been "designed by misanthropic aliens." The other concluded by saying, "Maybe I'm too idealistic, but I figure that in the main software interfaces should be more or less intuitive. ... It's not very intuitive."
Fair criticism. I hope this article helps clear this up.
The first thing to realize is that all of .NET is contained in what are called "class libraries." You might see the acronym FCL as you read about .NET. That's the Framework Class Library and if anything can be said to "be" .NET, that's it. You can see a list of the individual library files that are included at this link at Microsoft.
It's a long list. So only some of these are going to be referenced in any given project. Using VB Express 2010, for example, these are the references in a standard Windows Application and the actual files they are in.
System ---> System.dll System.Core ---> System.Core.dll System.Data ---> System.Data.dll System.Data.DataSetExtensions ---> System.Data.DataSetExtensions.dll System.Deployment ---> System.Deployment.dll System.Drawing ---> System.Drawing.dll System.Windows.Forms ---> System.Windows.Forms.dll System.Xml ---> System.Xml.dll System.Xml.Linq ---> System.Xml.Linq.dll
A major difference in the various "templates" that you can use for different types of projects (like Windows Application or Class Library) is the references that are automatically added to your project.
A key point to remember is that if a reference isn't part of the .NET Framework, you won't see any part of it in your project until a reference is added to the project. If you check the FCL reference linked earlier, you'll notice that Microsoft.VisualBasic.Compatibility.VB6 isn't there. Microsoft provides this particular library as a convenience for VB6 users and it's actually not part of .NET. So, if you plan to use it, you have to add it first.
The "default" configuration for both the VB.Net Express Edition and the full version of VB.NET in Visual Studio is to not display the references for a project. To see them, you have to click the Show All Files button in Solution Explorer, or look for them under the References tab of Project Designer. Since Project Designer has everything in it, let's look at that in more detail. You open it by clicking the ProjectName Properties ... button under the Project menu item, or by right-clicking your project in Solution Explorer and selecting Properties. Project Designer is shown below:
Click Here to display the illustration
The first thing to notice is that most of the tool is two large listboxs:
- Imported Namespaces
The main function of the top one, Referencesis to Add and Remove references using the buttons underneath it. You can also add references for Web Services here.
The Unused References ... and Reference Paths ... buttons helps you optomize your code by telling you if there are any class libraries that you don't need.
When you click Reference Paths ..., you get yet another dialog with a listbox. This one will probably be empty. The only thing that appears in the "Reference Paths" list box are entries that you put there. It's never populated with defaults (probably because you could screw up VB royally if you had access to the reference paths used by the system itself). So you can type a reference path to another system or select it using the browse button. You might need to do this for a third party system class library that you need. Then, any class libraries that are at that location are added to the "Add..." dialog list.".