开发者

Create .Net library with sub-assemblies

How can I create a dll in .NET that has sub-assemblies?

For example, if I have a project "MyUtilities", I'd like to create a sub-assembly "MyUtilities.EmailUtilities" with classes specific to emailing. Then, in a new project, when I add a reference to the compiled dll of MyUtilities, I could access the EmailUtilities classes using code like:

MyUtilities.EmailUtilities.EmailBlaster eBlaster = new MyUtilities.EmailUtilities.EmailBlaster开发者_如何学Python


What you want is a namespace.


You should make a single ordinary project with a subfolder called EmailUtilities.
This will create a separate namespace containing those classes.


You're mixing up namespaces and assemblies. They have nothing to do with each other. Namespaces can span across multiple assemblies, and assemblies can have multiple namespaces.

What you're describing is just sub-namespaces, which can be done all in code.

Either:

namespace MyUtilities
{
    namespace EmailUtilities
    {
         // Your code here
    }
}

Or, more commonly:

namespace MyUtilities.EmailUtilities
{
    // Your code here
}


You cannot create sub-assemblies in .NET, at least not the way you are thinking about. They only thing remotely close is satellite assemblies, but that is not what you want. What you should do is organize your classes into separate namespaces. Note that the namespaces can be nested.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜