Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
What is the difference between Module and Namespace in assembly
Posted
Comments
Sergey Alexandrovich Kryukov 29-Oct-12 23:13pm    
Totally incorrect question, like all questions about "difference". Can you tell us the difference between apple and Apple? :-) Same thing here.
--SA

1 solution

Modules are PE files (always with the extension .netmodule) which contain Metadata but they do not contain the assembly manifest. And hence in order to use a module, you have to create a PE file with the necessary assembly manifest. This makes the comparison of a module with assembly more relevant.

Read these:
Assembly and Module[^]
Assembly and Module - Part2[^]

Also read this: MSDN: Classes vs. Modules[^]

Namespaces are totally different - used to organize its many classes & control the scope of class and method names in larger programming projects. Thus more as an organizer.
Refer: MSDN: Namespaces (C# Programming Guide)[^]
 
Share this answer
 
Comments
Monjurul Habib 15-Oct-12 16:40pm    
5!
Sandeep Mewara 17-Oct-12 11:44am    
Thanks.
Sergey Alexandrovich Kryukov 29-Oct-12 23:15pm    
This is inaccurate. Every PE file is a module in .NET, including the one containing the manifest. It's called the main module of the assembly. You can easily find it out when you reflect the module(s) using Reflection. Even if you got this definition from Microsoft documentation, it's wrong, because it contradicts to the basic facts you can check up. (I did not vote this time, sorry.)
--SA
Sandeep Mewara 30-Oct-12 1:32am    
Interesting. It's OK about no vote SA. I shared what I knew and various article on web supported.

So, just to confirm, what you say is based on what you see via reflection? How can we prove it?
Sergey Alexandrovich Kryukov 30-Oct-12 10:22am    
By the way, how else would you call a single PE file created when you create a default single-module assembly? This is module, but of course it's principally different from those compiled as "module" and not making an assembly; as you correctly put it, without assembly manifest.

To prove? Through API which has certain terminology. I mean, you can create one-module assembly with Visual Studio, which actually don't support creating of extra modules, nor it supports putting already created modules in the assembly. So, you simply create an assembly in one of default ways, obtain a single PE file. You can load it using System.Reflection.Assembly.LoadFrom. For this assembly, you can get Modules (it's a property of System.Reflection.Assembly). For each module, you can get System.Reflection.Assembly.ManifestModule (the name of this property along already tells you that the file we are talking about is also called module). Finally, you can get each module (but if assembly is created with VS, there will be only one), and take System.Reflection.Module.FullyQualifiedName, to see what is it.

Logical, isn't it?
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900