473,395 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

namespace problem

hi again,

i have several namespacing problems in my big project.

my current namespaces in my solution are:

b2b.Server.Common
b2b.Server.Business
b2b.Server.Business.Mapping
b2b.Server.Business.Entities
b2b.Server.Database

now i have a testing app and i include all of those namespaces in that
app.
Server.Business.Mapping.Facility facility = new
Server.Business.Mapping();

works, but:

Business.Mapping.Facility facility...

or

Mapping.Facility facility...

doesnt work!! of course i have references to those librarys because i
can find them when i begin from Server... but not when i beging from
Business.. why?!
i never had those problems in VB.NET, only in c#..

thanks
Steve.
Nov 17 '05 #1
5 2152
Steven Wolf <ap****@gmx.net> wrote:
i have several namespacing problems in my big project.

my current namespaces in my solution are:

b2b.Server.Common
b2b.Server.Business
b2b.Server.Business.Mapping
b2b.Server.Business.Entities
b2b.Server.Database

now i have a testing app and i include all of those namespaces in that
app.
Server.Business.Mapping.Facility facility = new
Server.Business.Mapping();
Hang on - is Mapping a class as well as a namespace, or did you mean to
write new Server.Business.Mapping.Facility()?
works, but:

Business.Mapping.Facility facility...

or

Mapping.Facility facility...

doesnt work!! of course i have references to those librarys because i
can find them when i begin from Server... but not when i beging from
Business.. why?!
Because namespaces aren't treated in that way in C# - types in the
hierarchy "above" the declaring namespace are automatically included,
but the declaring namespace doesn't become a sort of "root".

Fortunately, with using declarations it shouldn't be a problem - just
declare

using Server.Business.Mapping;

at the top of your class.
i never had those problems in VB.NET, only in c#..


Indeed, C# doesn't treat namespaces in quite the same way as VB.NET.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #2
Hi Jon
Hang on - is Mapping a class as well as a namespace, or did you mean to
write new Server.Business.Mapping.Facility()?
No, Mapping is a namespace of b2b.Server.Business and Facility is a
class there.

I map there DataTables to my domain objects.


Fortunately, with using declarations it shouldn't be a problem - just
declare

using Server.Business.Mapping;

at the top of your class.

Well, the problem is, i have also a Facility class in
Server.Business.Entities, so i must use for example

Entities.Facility facility = new Entities.Facility();
Mapping.Facility facilityMapper = new Mapping.Facility();

and so on. but with declaring "using b2b.Server.Business", those both
namespaces (Entities and Mapping) don't appear..

Steve.
Nov 17 '05 #3
Steven Wolf <ap****@gmx.net> wrote:
Hang on - is Mapping a class as well as a namespace, or did you mean to
write new Server.Business.Mapping.Facility()?


No, Mapping is a namespace of b2b.Server.Business and Facility is a
class there.

I map there DataTables to my domain objects.


So you did mean to write new Server.Business.Mapping.Facility, right?
Fortunately, with using declarations it shouldn't be a problem - just
declare

using Server.Business.Mapping;

at the top of your class.

Well, the problem is, i have also a Facility class in
Server.Business.Entities, so i must use for example

Entities.Facility facility = new Entities.Facility();
Mapping.Facility facilityMapper = new Mapping.Facility();

and so on. but with declaring "using b2b.Server.Business", those both
namespaces (Entities and Mapping) don't appear..


You could write

using EntitiesFacility = b2b.Server.Business.Entities.Facility;
using MappingFacility = b2b.Server.Business.Mapping.Facility;

and then use "EntitiesFacility" and "MappingFacility" everywhere.

To be honest, I'd just change one set of class names - using the same
classnames in two different namespaces which are both likely to be used
in the same class is just asking for confusion.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #4
>
So you did mean to write new Server.Business.Mapping.Facility, right?

yes, exactly.

You could write

using EntitiesFacility = b2b.Server.Business.Entities.Facility;
using MappingFacility = b2b.Server.Business.Mapping.Facility;

and then use "EntitiesFacility" and "MappingFacility" everywhere.
wow, i never heard of that possibility, and thats exactly what i need,
thanks!

To be honest, I'd just change one set of class names - using the same
classnames in two different namespaces which are both likely to be used
in the same class is just asking for confusion.


yes, you are right, but i tried to keep the same mapper-class name as
the entity to map. I have also a b2b.Server.Database.Facility class,
it is similar to the datatable and represent a persistence object.

when i create an instance of them, i use faciltiyTable,
facilityEntity, facilityMapper and so on....

but anyway,
thank you for support.

Steven.
Nov 17 '05 #5
Steven Wolf <ap****@gmx.net> wrote:
You could write

using EntitiesFacility = b2b.Server.Business.Entities.Facility;
using MappingFacility = b2b.Server.Business.Mapping.Facility;

and then use "EntitiesFacility" and "MappingFacility" everywhere.


wow, i never heard of that possibility, and thats exactly what i need,
thanks!


Goodo.
To be honest, I'd just change one set of class names - using the same
classnames in two different namespaces which are both likely to be used
in the same class is just asking for confusion.


yes, you are right, but i tried to keep the same mapper-class name as
the entity to map. I have also a b2b.Server.Database.Facility class,
it is similar to the datatable and represent a persistence object.

when i create an instance of them, i use faciltiyTable,
facilityEntity, facilityMapper and so on....


Hmm... I still think you're liable to make things more confusing than
they need to be, but that's your choice - at least now you know how you
can do it!

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #6

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

Similar topics

8
by: Marcin Kalicinski | last post by:
Is the code below ill formed (because operator >> is defined in different namespace than class B)? It fails with VS 2005 Beta. I don't know if I should redesign my code or if I should find a...
5
by: Mike Oliszewski | last post by:
Given the following c# code: namespace Company2 { public class SomeFunctions { public void FunctionA() { // Do Something. }
4
by: Kevin Newman | last post by:
The primary problem I've had with php is the lack of namespaces, which makes OOP very difficult to organize, since you end up with large number of classes cluttering up the same namespace - which...
30
by: Pep | last post by:
Is it best to include the code "using namespace std;" in the source or should each keyword in the std namespace be qualified by the namespace tag, such as std::cout << "using std namespace" <<...
7
by: Armin Zingler | last post by:
Hi all, I have a Form called "Main": Public Class Main Private Sub Button1_Click( _ ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles Button1.Click
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...

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.