none
Confusion between Assembly and Namespace RRS feed

  • Question

  • Hi,

    We can view the references of our project in the solutions window under the "references" tab. In the picture you see I have selected the "System.Data" reference and in the properties window I find it is of DLL type. My question is that the reference "System.Data" refers to a namespace or an assembly? My confusion arises from the following:

    I know assemblies can be of two types: DLL and EXE. And since the extension for System.Data is seen to be DLL I conclude it is an assembly.

    However, if I want to use a StringBuilder class then I have to use the statement "Import System.Text". Now my understanding is that when we are importing "System.Text" we are asking VB to look into the NAMESPACE "System.Text" where the Stringbuilder class resides. Also the Stringbuilder class is like an assembly of DLL type.

    Conclusion and My confusion: When I look the stringbuilder example I feel "System.Text" is the "Namespace" but if I look at the properties windows I feel "System.Data" is the assembly (because it of DLL type). Can anyone pls help clear the confusion?


    Sougata Ghosh

    Sunday, June 3, 2018 8:25 AM

Answers

  • First thing to do is review Namespaces documentation.

    In regards to StringBuilder class, its physically located in mscorlib.dll.

    Here is the top of the class with the namespace (yes it's C# source code as this is what the class was written in).

    // Decompiled with JetBrains decompiler
    // Type: System.Text.StringBuilder
    // Assembly: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    // MVID: 2A55D587-43EC-479C-866B-425E85A3236D
    // Assembly location: C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll
    
    using System.Runtime.CompilerServices;
    using System.Runtime.InteropServices;
    using System.Runtime.Serialization;
    using System.Security;
    
    namespace System.Text
    {
      /// <summary>Represents a mutable string of characters. This class cannot be inherited.
      /// To browse the .NET Framework source code for this type, see the Reference Source.
      /// </summary>
      /// <filterpriority>1</filterpriority>
      [ComVisible(true)]
      [Serializable]
      public sealed class StringBuilder : ISerializable


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    • Marked as answer by sougata12 Tuesday, June 5, 2018 5:00 PM
    Sunday, June 3, 2018 3:49 PM
    Moderator
  • The first thing to understand is that there are many types of DLLs. People should not just say DLL without specifying the type of DLL. When I say type of DLL I mean that unless a DLL is a native DLL it has extra stuff that requires special processing. A COM DLL has special stuff that makes it a COM DLL and a Class Library also has special stuff (metadata).

    Next, the VB.Net keyword import is misleading. It imports nothing, it just provides default qualification.

    COM objects have something called a type library that specifies what data and methods that the COM object uses or can be used for. For .Net the type library data is most of what the metadata (see Metadata and Self-Describing Components) is for Class Libraries. When you add a reference to a Class Library you are actually making a pointer (I say pointer in a general sense, not a specific memory pointer) to a DLL with type data in it.

    COM objects and .Net assemblies can both exist in either an exe or a dll file but .Net class libraries must exist in dll files so in this context it is confusing to say that System.Data refers to an assembly.



    Sam Hobbs
    SimpleSamples.Info

    • Marked as answer by sougata12 Tuesday, June 5, 2018 4:59 PM
    Sunday, June 3, 2018 6:11 PM

All replies

  • It is in the .Net framework

    https://docs.microsoft.com/en-us/dotnet/standard/class-library-overview

    Probably you confuse Class Libraries DLL's with Dynamic link libraries DLL's 

    The extension DLL is used for much more.

    That is also the reason why the deployment part of .Net VB is so much smaller than the old Com VB 


    Success
    Cor


    Sunday, June 3, 2018 8:54 AM
  • First thing to do is review Namespaces documentation.

    In regards to StringBuilder class, its physically located in mscorlib.dll.

    Here is the top of the class with the namespace (yes it's C# source code as this is what the class was written in).

    // Decompiled with JetBrains decompiler
    // Type: System.Text.StringBuilder
    // Assembly: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    // MVID: 2A55D587-43EC-479C-866B-425E85A3236D
    // Assembly location: C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll
    
    using System.Runtime.CompilerServices;
    using System.Runtime.InteropServices;
    using System.Runtime.Serialization;
    using System.Security;
    
    namespace System.Text
    {
      /// <summary>Represents a mutable string of characters. This class cannot be inherited.
      /// To browse the .NET Framework source code for this type, see the Reference Source.
      /// </summary>
      /// <filterpriority>1</filterpriority>
      [ComVisible(true)]
      [Serializable]
      public sealed class StringBuilder : ISerializable


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    • Marked as answer by sougata12 Tuesday, June 5, 2018 5:00 PM
    Sunday, June 3, 2018 3:49 PM
    Moderator
  • The first thing to understand is that there are many types of DLLs. People should not just say DLL without specifying the type of DLL. When I say type of DLL I mean that unless a DLL is a native DLL it has extra stuff that requires special processing. A COM DLL has special stuff that makes it a COM DLL and a Class Library also has special stuff (metadata).

    Next, the VB.Net keyword import is misleading. It imports nothing, it just provides default qualification.

    COM objects have something called a type library that specifies what data and methods that the COM object uses or can be used for. For .Net the type library data is most of what the metadata (see Metadata and Self-Describing Components) is for Class Libraries. When you add a reference to a Class Library you are actually making a pointer (I say pointer in a general sense, not a specific memory pointer) to a DLL with type data in it.

    COM objects and .Net assemblies can both exist in either an exe or a dll file but .Net class libraries must exist in dll files so in this context it is confusing to say that System.Data refers to an assembly.



    Sam Hobbs
    SimpleSamples.Info

    • Marked as answer by sougata12 Tuesday, June 5, 2018 4:59 PM
    Sunday, June 3, 2018 6:11 PM
  • https://msdn.microsoft.com/en-us/library/system.text.stringbuilder%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396

    All you have to do is use Bing or Google to look-up what namespace the StringBuilder class is in or class in the .NET Framework is in for that matter. The documentation is there.

    Sunday, June 3, 2018 7:12 PM