Connecting Tech Pros Worldwide Help | Site Map

Sub-libraryies in a main library

  #1  
Old November 18th, 2008, 04:45 PM
Curious
Guest
 
Posts: n/a
I was asked to create a C#.NET Console Library project that contains
two sub-libraries. And each sub-library contains multiple utilties.

As an experiment, I've created a Console Library project (solution).
Then I've added two projects (they're supposed to be sub-libraries).
However, each project has its own indepent assembly in the form of
a .dll file.

It seems that there is no way I can create a unified assembly (a
single .dll file) containing both projects (or libraries). Any input
on how to solve this problem? I work with business people who don't
know .NET and they request me to do it this way.
  #2  
Old November 18th, 2008, 05:05 PM
=?Utf-8?B?RmFtaWx5IFRyZWUgTWlrZQ==?=
Guest
 
Posts: n/a

re: Sub-libraryies in a main library




"Curious" wrote:
Quote:
I was asked to create a C#.NET Console Library project that contains
two sub-libraries. And each sub-library contains multiple utilties.
>
As an experiment, I've created a Console Library project (solution).
Then I've added two projects (they're supposed to be sub-libraries).
However, each project has its own indepent assembly in the form of
a .dll file.
>
It seems that there is no way I can create a unified assembly (a
single .dll file) containing both projects (or libraries). Any input
on how to solve this problem? I work with business people who don't
know .NET and they request me to do it this way.
>
You could ask them what they mean...

My first impression though would be to create two folders such as SubLib1
and SubLib2 in your single library project. This gives the classes created
in each folder different namespaces such as Project.SubLib1.Class1,
Project.SubLib2.Class2. It still compiles to a single dll. You don't need
to put the classes in separate folders as you could simply change the
namespaces in the class files, but I find it easier to manage them this way.


  #3  
Old November 19th, 2008, 02:05 PM
Curious
Guest
 
Posts: n/a

re: Sub-libraryies in a main library


On Nov 18, 12:01*pm, Family Tree Mike
<FamilyTreeM...@discussions.microsoft.comwrote:
Quote:
"Curious" wrote:
Quote:
I was asked to create a C#.NET Console Library project that contains
two sub-libraries. And each sub-library contains multiple utilties.
>
Quote:
As an experiment, I've created a Console Library project (solution).
Then I've added two projects (they're supposed to be sub-libraries).
However, each project has its own indepent assembly in the form of
a .dll file.
>
Quote:
It seems that there is no way I can create a unified assembly (a
single .dll file) containing both projects (or libraries). Any input
on how to solve this problem? I work with business people who don't
know .NET and they request me to do it this way.
>
You could ask them what they mean...
>
My first impression though would be to create two folders such as SubLib1
and SubLib2 in your single library project. *This gives the classes created
in each folder different namespaces such as Project.SubLib1.Class1,
Project.SubLib2.Class2. *It still compiles to a single dll. *You don't need
to put the classes in separate folders as you could simply change the
namespaces in the class files, but I find it easier to manage them this way.
They want a single assembly that contains a hierarchy of namespaces.
For instance, the assembly is "Utilities". There are two sub-libraries
(sub-namespaces) under "Utilities" called "Lib1" and "Lib2".

When I use each library, I use either namespace "Utilities.Lib1" or
namespace "Utilities.Lib2".

Question regarding your suggestion: I believe by project, you mean
"solution". Is that the case? Do I need to create multiple projects
under the solution for multiple sub-libraries? I guess not, because
that would result in multiple assemblies.

Shall I manually add the folders on the hard drive when I create the
project? How will the solution/pro
  #4  
Old November 19th, 2008, 05:05 PM
=?Utf-8?B?RmFtaWx5IFRyZWUgTWlrZQ==?=
Guest
 
Posts: n/a

re: Sub-libraryies in a main library




"Curious" wrote:
Quote:
>
They want a single assembly that contains a hierarchy of namespaces.
For instance, the assembly is "Utilities". There are two sub-libraries
(sub-namespaces) under "Utilities" called "Lib1" and "Lib2".
>
When I use each library, I use either namespace "Utilities.Lib1" or
namespace "Utilities.Lib2".
>
Question regarding your suggestion: I believe by project, you mean
"solution". Is that the case? Do I need to create multiple projects
under the solution for multiple sub-libraries? I guess not, because
that would result in multiple assemblies.
>
Shall I manually add the folders on the hard drive when I create the
project? How will the solution/pro
>
No, your solution should only need one project. This is why you had
multiple dlls created. To create a single dll, just have one project. In
the solution explorer, right click the project, and one of the options is
"Add" -"New Folder".

Now when you right click on the folder you just created, you can create a
class in that folder defaulting to the folder name as part of the namespace.
In your case, it appears your solution/project will be named "Utilities", and
you will have two folders called "lib1" and "lib2".

Mike

  #5  
Old November 19th, 2008, 05:05 PM
=?Utf-8?B?RmFtaWx5IFRyZWUgTWlrZQ==?=
Guest
 
Posts: n/a

re: Sub-libraryies in a main library



Further info that I just realized I left off my most recent post.

Simply dragging class files that previously existed into the folder will not
change their namespace. The approach I am describing is how I start out a
project. Should you choose to go this way with previously existing class
files, you would need to manually change their namespaces.

Mike
  #6  
Old November 19th, 2008, 06:45 PM
Curious
Guest
 
Posts: n/a

re: Sub-libraryies in a main library


Thanks Mike for the advice! Now I've got it.

If I encounter any problems, I'll post in this thread again.
  #7  
Old November 21st, 2008, 04:05 PM
Curious
Guest
 
Posts: n/a

re: Sub-libraryies in a main library


Thanks Mike for the advice! It works.
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sub-libraries in a main library - Is this possible? Curious answers 2 November 19th, 2008 01:45 PM
Running sub in a separate process John answers 3 April 29th, 2007 11:35 PM
Running sub in a separate process John answers 3 April 29th, 2007 11:35 PM
Newby Question : Update to Sub Main in vb.net Fred Nelson answers 17 November 21st, 2005 05:29 AM
Thread.Start in sub main Bob Day answers 4 November 20th, 2005 01:27 PM