Namespace or Assembly?

后端 未结 9 722
长发绾君心
长发绾君心 2020-12-12 14:20

I am getting very confused between Namespaces and Assemblies. Are System.Data and System.Web Namespaces or Assemblies?

I have noticed these

相关标签:
9条回答
  • 2020-12-12 14:54

    Assembly is physical grouping of logical units, Namespace, logically groups classes.

    Namespace can span multiple assembly

    0 讨论(0)
  • 2020-12-12 14:56

    System.Data is a namespace, System.Data.DLL (the file) is an assembly.

    A namespace is a logical grouping of types (mostly to avoid name collisions). An assembly can contain types in multiple namespaces (System.DLL contains a few...), and a single namespace can be spread across assemblies (e.g. System.Threading).

    0 讨论(0)
  • 2020-12-12 14:56

    They are namespaces.Assemblies contains more than one namespace.For Example: System.dll contains these namespaces (and more):

    enter image description here

    Also one namespace might contain nested namespaces.They are just logical names to organize the code.Just be aware, a DLL files are assemblies that contains namespace(s).

    GAC is Global Assembly Cache. According to MSDN:

    The global assembly cache stores assemblies specifically designated to be shared by several applications on the computer.

    So commonly used assemblies stored in the GAC and therefore you don't need to copy all assembly files to your project directory that you are referencing from your project.The assemblies stored in the GAC are Strong-Named assemblies.Normally when you add a reference to an assembly from your project that is not Strong-Named a copy of your .dll file will be created on your bin\Debug folder..If you wish you can make your assembly (class library project for example) Strong-Named.See: How to: Sign an Assembly with a Strong Name

    0 讨论(0)
提交回复
热议问题