470,593 Members | 2,397 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,593 developers. It's quick & easy.

Implementing a namespace over more than one assembly?

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 22 '05 #1
4 1890
Actually you can see this very thing in action in some of MSs own
assemblies...

System.Data namespace which is (i believe) defined in mscorlib.dll.
System.Data.OracleClient which is defined in the
System.Data.OracleClient.dll

I dont know how name resolution would work though if you had two classes
named the same
from two different assemblies in the same namespace both in reference in one
project.

I did something VERY similar to your project... what i did, is i made myself
one root assembly which
had my base classes defined, from which the individual providers all
inherited (significant shared code).

I put that in dll My.Data.dll (for example)
Then i put the base classes in their in the namespace My.Data.Definitions

Then each provider can be written in its own assembly such as :

My.Data.Oracle.dll where NS = My.Data.Oracle
My.Data.SqlServer.dll where NS = My.Data.SqlServer
My.Data.ODBC.dll where NS = My.Data.ODBC and so on.

Then you ref in your project the base dll My.Data.dll, and the appropriate
one for whichever provider you need.

HTH.
"thechaosengine" <na> wrote in message
news:43*********************@news.microsoft.com...
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 22 '05 #2

"Arthur Dent" <hi*********************@yahoo.com> wrote in message
news:ed**************@tk2msftngp13.phx.gbl...
Actually you can see this very thing in action in some of MSs own
assemblies...

System.Data namespace which is (i believe) defined in mscorlib.dll.
System.Data.OracleClient which is defined in the
System.Data.OracleClient.dll

I dont know how name resolution would work though if you had two classes
named the same
from two different assemblies in the same namespace both in reference in
one


To add additional assemblies that do this:

mscorlib.dll - Defines most of the System root namespace's classes.
System.dll - Defines only a few of the System root namespace's classes.

HTH :)

Mythran

Nov 22 '05 #3
Gentlemen, thank you kindly for your advice. You have both been a great help.

Thanks again

Kindest Regards

tce
"Arthur Dent" <hi*********************@yahoo.com> wrote in message
news:ed**************@tk2msftngp13.phx.gbl...
Actually you can see this very thing in action in some of MSs own
assemblies...

System.Data namespace which is (i believe) defined in mscorlib.dll.
System.Data.OracleClient which is defined in the
System.Data.OracleClient.dll

I dont know how name resolution would work though if you had two
classes
named the same
from two different assemblies in the same namespace both in reference
in
one

To add additional assemblies that do this:

mscorlib.dll - Defines most of the System root namespace's classes.
System.dll - Defines only a few of the System root namespace's
classes.

HTH :)

Mythran

Nov 22 '05 #4
Gentlemen, thank you kindly for your advice. You have both been a great help.

Thanks again

Kindest Regards

tce
"Arthur Dent" <hi*********************@yahoo.com> wrote in message
news:ed**************@tk2msftngp13.phx.gbl...
Actually you can see this very thing in action in some of MSs own
assemblies...

System.Data namespace which is (i believe) defined in mscorlib.dll.
System.Data.OracleClient which is defined in the
System.Data.OracleClient.dll

I dont know how name resolution would work though if you had two
classes
named the same
from two different assemblies in the same namespace both in reference
in
one

To add additional assemblies that do this:

mscorlib.dll - Defines most of the System root namespace's classes.
System.dll - Defines only a few of the System root namespace's
classes.

HTH :)

Mythran

Nov 22 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Phill. W | last post: by
29 posts views Thread by Tiraman | last post: by
1 post views Thread by Dan Holmes | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.