none
.Net Framework Class Library namespaces RRS feed

  • Question

  • Looking through the MSDN library documentation section >Net Framework SDK .Net Framework > .Net Framework Class Library the namespaces are either Microsoft.* or System.*, plus a very small number of other ones - Default Namespace, Accessibility etc

    My questions are
    1. What is the difference, ie what makes the Microsoft developers put a class in one or the other
    2. In my development work I have exclusively used classes from System.*, what work would I have to be doing to use more of the Microsoft.* classes?
    Friday, September 19, 2008 12:29 PM

Answers

  • The majority of the framework is in System.  System represents the core framework irrelevant of where it is implemented.  The Microsoft namespace is used for all Microsoft products.  The core framework ships with a few Microsoft namespaces but the contents thereof are technically part of a separate application.  I suspect they were/are developed by the appropriate group at MS.  Examples include the language libraries such as VB, C# and J#.  Office, SQL and all other MS products will appear in their own Microsoft namespace and might or might not ship as part of the core framework.

    There is no relative importance of whether you use more System or Microsoft namespaces.  The reality is that the core framework you'll generally be using is in System so that is the namespace root you'll use most often.  However VB devs almost always also include at least the VB libraries as well (which are in Microsoft).  At the end of the day it just boils down to how MS decided to split things up.

    In your own code you should follow the standard practice of naming your namespace:  <company>.<product>.<more>.  You should never create your namespaces starting with System or Microsoft as these could collide with the framework in the future.

    Oh in response to your 2nd question you'd be using Microsoft.VisualBasic if you were working with VB, Microsoft.Office if you were doing any Office development and Microsoft.SqlServer if you were doing in SQL-specific work like creating SQL assemblies or working with its advanced services.  For generic WinForms/ASP.NET apps you'll be normally using System.  Microsoft.VisualBasic does have some really useful classes in it so you are encouraged to look at this namespace and perhaps include the assembly in any of your projects.  You don't have to use it with just VB.

    Michael Taylor - 9/19/08
    http://p3net.mvps.org
    • Marked as answer by Zhi-Xin Ye Wednesday, September 24, 2008 10:49 AM
    Friday, September 19, 2008 1:32 PM
    Moderator