473,516 Members | 3,064 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

A namespace implemented over several different assemblies?

Hi all,

Can anyone tell me if it is advisable (or even possible) to define a namespace
across 2 or more assemblies?

For example, consider the namespace SampleApplication.Data.Providers

Would it be possible to have assembly A define a class as part of that namespace
as well as Assembly B also declaring a class to be within it as well?

In particular, I have a number of data providers. It would be useful (I think)
to declare them in the same namespace, but for the purposes of a demonstration
I'm doing, each provider must exisit in its own seperately deployed assembly.

Is this possible and is it a good idea?

Thanks to anyone who can share some advice! :-)

Kindest Regards

tce
Nov 17 '05 #1
7 8424
It's definitely possible and there is nothing wrong with it. The .NET
framework itself has namespaces spread across multiple assemblies. For
example, the System.Data namespace and the System.Web, System.Web,
System.Drawing, etc., etc., etc. namespaces are implemented in multiple
assemblies.

It's perfectly fine in my opinion as long as it is clear to the users of
your class library that what assembly they will need to reference for given
functionality.
Hope this helps.

Brian Delahunty
Ireland

http://briandela.com/blog
"thechaosengine" wrote:
Hi all,

Can anyone tell me if it is advisable (or even possible) to define a namespace
across 2 or more assemblies?

For example, consider the namespace SampleApplication.Data.Providers

Would it be possible to have assembly A define a class as part of that namespace
as well as Assembly B also declaring a class to be within it as well?

In particular, I have a number of data providers. It would be useful (I think)
to declare them in the same namespace, but for the purposes of a demonstration
I'm doing, each provider must exisit in its own seperately deployed assembly.

Is this possible and is it a good idea?

Thanks to anyone who can share some advice! :-)

Kindest Regards

tce

Nov 17 '05 #2
I would say that, while possible to do this, it is not necessarily best
practice. For management purposes, you will want to encapsulate an
entire namespace in a single assembly. This will help with maintenance
down the line, and will also help avoid silly problems like duplicate
class names in the same namespace (but different assemblies).

The .NET Framework IS indeed split into multiple assemblies, but I do
not know of a case where a single namespace is split accross
assemblies. By that, I mean that while the System.Web and
System.Web.Mobile namespaces may be split into multiple assemblies, you
will not find System.Web itself in multiple assemblies.

I hope this helps,

Tim Aranki

Nov 17 '05 #3
Tim,

Actually, there are a number of namespaces with functionality split
between System.dll and mscorlib.dll (System, System.Net, System.IO, etc,
etc). Of course, this doesn't really matter so much, because pretty much
every program in existence is going to have references to these two
assemblies (as a matter of fact, the C# compiler automatically references
mscorlib.dll by default unless you tell it not to).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"tim.aranki" <ti********@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
I would say that, while possible to do this, it is not necessarily best
practice. For management purposes, you will want to encapsulate an
entire namespace in a single assembly. This will help with maintenance
down the line, and will also help avoid silly problems like duplicate
class names in the same namespace (but different assemblies).

The .NET Framework IS indeed split into multiple assemblies, but I do
not know of a case where a single namespace is split accross
assemblies. By that, I mean that while the System.Web and
System.Web.Mobile namespaces may be split into multiple assemblies, you
will not find System.Web itself in multiple assemblies.

I hope this helps,

Tim Aranki

Nov 17 '05 #4
System.Web is in both System.dll and System.Web.dll with classes from the
namespace in both dll's. The System namespace itself is split across multiple
dll's. System.Resources is split across multiple dll's, System.Xml has
classes in System.dll and System.Xml.dll, etc., etc., etc.. There are a
number of namespaces like this. Reflector is a great tool :-)

I know that it can lead to issues with management down the line and I should
have addressed that in my response but I was just trying to say that it's
possible and it's done by the .NET framework itself. I agree completely that
it could lead to issues.

--
Brian Delahunty
Ireland

http://briandela.com/blog
"tim.aranki" wrote:
I would say that, while possible to do this, it is not necessarily best
practice. For management purposes, you will want to encapsulate an
entire namespace in a single assembly. This will help with maintenance
down the line, and will also help avoid silly problems like duplicate
class names in the same namespace (but different assemblies).

The .NET Framework IS indeed split into multiple assemblies, but I do
not know of a case where a single namespace is split accross
assemblies. By that, I mean that while the System.Web and
System.Web.Mobile namespaces may be split into multiple assemblies, you
will not find System.Web itself in multiple assemblies.

I hope this helps,

Tim Aranki

Nov 17 '05 #5
Tim,
The System.Uri type is in the System assembly, while System.String type is
in the mscorlib assembly.

Most of System.Xml is in the System.Xml assembly, while
System.Xml.XmlDataDocument is in the System.Data assembly.

System.Diagnostics is split between the mscorlib & System assemblies. As
well as a number of other namespaces are split between mscorlib & System
assemblies.

System.Web is split between the System & System.Web assemblies.

I'm sure there are others, I just tried to highlight the "common" ones...

Although I agree spliting may not always make sense, in the case of
XmlDataDocument I think it makes sense to include it in the System.Xml
namespace, however to gain access to internal/friend methods of the DataSet
object model, it makes sense to have it in the System.Data assembly..

Hope this helps
Jay
"tim.aranki" <ti********@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
|I would say that, while possible to do this, it is not necessarily best
| practice. For management purposes, you will want to encapsulate an
| entire namespace in a single assembly. This will help with maintenance
| down the line, and will also help avoid silly problems like duplicate
| class names in the same namespace (but different assemblies).
|
| The .NET Framework IS indeed split into multiple assemblies, but I do
| not know of a case where a single namespace is split accross
| assemblies. By that, I mean that while the System.Web and
| System.Web.Mobile namespaces may be split into multiple assemblies, you
| will not find System.Web itself in multiple assemblies.
|
| I hope this helps,
|
| Tim Aranki
|
Nov 17 '05 #6
I should have known better...and Reflector is sitting on my desktop
even!

I still think that it can be a dangerous practice, and I expect that
there were significant driving forces behind those decisions by the
team at MS (The Xml one comes to mind as a necessary evil). The System
and mscorlib coupling makes sense to a point, but I would be interested
in knowing the real driving forces that lead to namespaces needing to
be split... To me namespaces delimit objects in a common domain (XML,
Web, Messaging, etc), so when I need to reference that namespace to use
it's functionality, I would not expect to have to reference multiple
assemblies. Perhaps it was/is assumed that all (or at least the vast
majority of) projects would need both the mscorlib and System
assemblies, and therefore it was not such a bad thing to do? While
that is probably true, it just does not seem as elegant to me.

Or perhaps I am just plain crazy! :)

So, do we agree that is is not "best practice", but possible to do when
design/architecture necessitates?

/tim

Nov 17 '05 #7
Tim,
| So, do we agree that is is not "best practice", but possible to do when
| design/architecture necessitates?

That's my general feeling on it.

However! I've also used multiple assemblies & a single namespace, where I
wanted multiple assemblies to manage the sheer number of types, however
those types made the most sense in a single namespace. Basically each class
was a plug-in, there were a handful of closely related plug-ins in a single
assembly, the various plug-ins were dynamically loaded based on criteria met
in the program. The plug-in (class), along with its assembly were listed in
the app.config based on a "key"...

Hope this helps
Jay

"tim.aranki" <ti********@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
|I should have known better...and Reflector is sitting on my desktop
| even!
|
| I still think that it can be a dangerous practice, and I expect that
| there were significant driving forces behind those decisions by the
| team at MS (The Xml one comes to mind as a necessary evil). The System
| and mscorlib coupling makes sense to a point, but I would be interested
| in knowing the real driving forces that lead to namespaces needing to
| be split... To me namespaces delimit objects in a common domain (XML,
| Web, Messaging, etc), so when I need to reference that namespace to use
| it's functionality, I would not expect to have to reference multiple
| assemblies. Perhaps it was/is assumed that all (or at least the vast
| majority of) projects would need both the mscorlib and System
| assemblies, and therefore it was not such a bad thing to do? While
| that is probably true, it just does not seem as elegant to me.
|
| Or perhaps I am just plain crazy! :)
|
| So, do we agree that is is not "best practice", but possible to do when
| design/architecture necessitates?
|
| /tim
|
Nov 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1466
by: thechaosengine | last post by:
Hi all, Can anyone tell me if it is advisable (or even possible) to define a namespace across 2 or more assemblies? For example, consider the namespace SampleApplication.Data.Providers Would it be possible to have assembly A define a class as part of that namespace as well as Assembly B also declaring a class to be within it as well?
3
406
by: thechaosengine | last post by:
Hi all, Can anyone tell me if it is advisable (or even possible) to define a namespace across 2 or more assemblies? For example, consider the namespace SampleApplication.Data.Providers Would it be possible to have assembly A define a class as part of that namespace as well as Assembly B also declaring a class to be within it as well?
10
2839
by: Richard Brown | last post by:
I think I might be on track to a misnomer that I keep running into. A lot of the assemblies that I reference are named "System", "System.Drawing", etc. There are dlls, ie, system.dll and system.drawing.dll", etc. However, in my Imports statements, I also use Import System and Import System.Drawing, which I assume are 'namespaces'. So,...
6
1404
by: jeffo | last post by:
Hello everyone I'm looking at an example in the MSDN library and it says that this code requires a reference to the system namesppace. What does this mean? Thanks in advance.
10
6634
by: anders | last post by:
I have 2 external assemblies A1 and A2 that both define class X in the global namespace. I need to use both assemblies in my VB project but the names X are ambiguous. How can I get around this problem? Is there a way to refer to the assembly, f.ex. A1.X and A2.X (this syntax does not compile). Or can I change the name X in the Imports...
11
3893
by: alex sparsky | last post by:
I have a rather unique problem that I need some advice on. I have multiple c# controls that need to make use of a common namespace. So when I go to include both controls that make use of that common namespace and one control has a newer version of that namespace, the compiler complains about ambiguous references. I've tried using...
1
2080
by: peeping_t | last post by:
I´m currently writing an application that will have some plugin functionality and therefor I´ve created two projects one that will build the exe and one that contains the "framework" for the application as a dll, which also contains reusable controls that the application and "plugin developers" use. I was suprised that I couldn´t load a...
12
2161
by: bgeneto | last post by:
I know that it's a very basic question, but I can't figure out or find an answer to why do we have to specify a namespace, like this #include<string> using namespace std; when using the standard string library? Is this really necessary, why? Thanks, Bernhard Enders.
27
1807
by: HKSHK | last post by:
Hello, I have this problem: I wrote some DLLs with VB.Net 2003 which I use with my programs. But I want to avoid that I have to go down to "DLL hell" and to copy all used dlls into each program directory. Does anyone have an idea how I can avoid that? Thanks in advance!
0
7276
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7182
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7581
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7142
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7548
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5110
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3267
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3259
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1624
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.