473,386 Members | 1,609 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,386 software developers and data experts.

Interesting namespace conflict problem

I am having an interesting namespace conflict. When we use a third party
lib we create a company assembly for any descending classes to go in. I
have simplified the problem into the example below.

We are using the third party assembly Abc.Reports so we have an assembly
called ComanyName.Abc.

The problem is when I try to use the class Abc.Reports.Thing it tries to
find it in CompanyName.Abc.Reports.Thing.

It is assuming I have entered a partial namespace path when actually I have
entered a complete path.
What I really need is some way to tell it that it is the full path from the
root like: root.Abc.Reports.Thing.
Is there a way to specifiy that it is the full path?

This can normally be solved by having a "using Abc.Reports" at the top and
then just working with "Thing" but in this case I cannot because "Thing"
exists ambiguously in two places in the third party lib.

Of course I can fix this by just renaming our namespace but I thought it was
an interesting problem that you can't tell the compiler that you are
referring to the full path, or can you?

Example code:

namespace CompanyName.Abc
{
public class MyClass
{
// Get a compile error here:
// I have specified the full namespace path but
// it tries to look for CompanyName.Abc.Reports.Thing
private Abc.Reports.Thing Thing;
}
}

--
Andrew Cutforth - AJC Software - www.ajcsoft.com
The best folder synchronize and directory compare tool available.
AJC Active Backup instantly archives every file you edit giving you
unlimited undo and automatic revision control. Never lose your data again.
Jun 27 '08 #1
4 1867
Silly me

its global::Abc.Reports.Thing

--
Andrew Cutforth - AJC Software - www.ajcsoft.com
The best folder synchronize and directory compare tool available.
AJC Active Backup instantly archives every file you edit giving you
unlimited undo and automatic revision control. Never lose your data again.

"Andrew" <so*****@nospam.comwrote in message
news:Os**************@TK2MSFTNGP03.phx.gbl...
>I am having an interesting namespace conflict. When we use a third party
lib we create a company assembly for any descending classes to go in. I
have simplified the problem into the example below.

We are using the third party assembly Abc.Reports so we have an assembly
called ComanyName.Abc.

The problem is when I try to use the class Abc.Reports.Thing it tries to
find it in CompanyName.Abc.Reports.Thing.

It is assuming I have entered a partial namespace path when actually I
have entered a complete path.
What I really need is some way to tell it that it is the full path from
the root like: root.Abc.Reports.Thing.
Is there a way to specifiy that it is the full path?

This can normally be solved by having a "using Abc.Reports" at the top and
then just working with "Thing" but in this case I cannot because "Thing"
exists ambiguously in two places in the third party lib.

Of course I can fix this by just renaming our namespace but I thought it
was an interesting problem that you can't tell the compiler that you are
referring to the full path, or can you?

Example code:

namespace CompanyName.Abc
{
public class MyClass
{
// Get a compile error here:
// I have specified the full namespace path but
// it tries to look for CompanyName.Abc.Reports.Thing
private Abc.Reports.Thing Thing;
}
}

--
Andrew Cutforth - AJC Software - www.ajcsoft.com
The best folder synchronize and directory compare tool available.
AJC Active Backup instantly archives every file you edit giving you
unlimited undo and automatic revision control. Never lose your data
again.


Jun 27 '08 #2
On Apr 25, 7:41*am, "Andrew" <some...@nospam.comwrote:
I am having an interesting namespace conflict. *When we use a third party
lib we create a company assembly for any descending classes to go in. *I
have simplified the problem into the example below.

We are using the third party assembly Abc.Reports so we have an assembly
called ComanyName.Abc.

The problem is when I try to use the class Abc.Reports.Thing it tries to
find it in CompanyName.Abc.Reports.Thing.

It is assuming I have entered a partial namespace path when actually I have
entered a complete path.
What I really need is some way to tell it that it is the full path from the
root like: root.Abc.Reports.Thing.
Is there a way to specifiy that it is the full path?

This can normally be solved by having a "using Abc.Reports" at the top and
then just working with "Thing" but in this case I cannot because "Thing"
exists ambiguously in two places in the third party lib.

Of course I can fix this by just renaming our namespace but I thought it was
an interesting problem that you can't tell the compiler that you are
referring to the full path, or can you?
Honestly, I would rename your namespace and be done with it. Cause if
you think about the same problem can present to another developer
under your same escenario.

In any case global:: prefix will solve your problem
Jun 27 '08 #3
On Apr 25, 6:41*am, "Andrew" <some...@nospam.comwrote:
This can normally be solved by having a "using Abc.Reports" at the top and
then just working with "Thing" but in this case I cannot because "Thing"
exists ambiguously in two places in the third party lib.
Well, this may come as a shock, but that isn't necessarily true. And
in the interest of discussing other namespace oddities consider this
example which I've posted several times before in this group.

// The following line imports namespace B types (Bar1 & Bar2).
using B;
namespace A.C.D
{
// The following line imports namespace A.B types (Foo1 & Foo2).
using B;
}

namespace A.B
{
public class Foo1 { }
public class Foo2 { }
}

namespace B
{
public class Bar1 { }
public class Bar2 { }
}
Jun 27 '08 #4
Perhaps using ABC = Namespace.subNamespace.ABC;

"Andrew" <so*****@nospam.comwrote in message
news:Os**************@TK2MSFTNGP03.phx.gbl...
I am having an interesting namespace conflict. When we use a third party
lib we create a company assembly for any descending classes to go in. I
have simplified the problem into the example below.

We are using the third party assembly Abc.Reports so we have an assembly
called ComanyName.Abc.

The problem is when I try to use the class Abc.Reports.Thing it tries to
find it in CompanyName.Abc.Reports.Thing.

It is assuming I have entered a partial namespace path when actually I
have entered a complete path.
What I really need is some way to tell it that it is the full path from
the root like: root.Abc.Reports.Thing.
Is there a way to specifiy that it is the full path?

This can normally be solved by having a "using Abc.Reports" at the top and
then just working with "Thing" but in this case I cannot because "Thing"
exists ambiguously in two places in the third party lib.

Of course I can fix this by just renaming our namespace but I thought it
was an interesting problem that you can't tell the compiler that you are
referring to the full path, or can you?

Example code:

namespace CompanyName.Abc
{
public class MyClass
{
// Get a compile error here:
// I have specified the full namespace path but
// it tries to look for CompanyName.Abc.Reports.Thing
private Abc.Reports.Thing Thing;
}
}

--
Andrew Cutforth - AJC Software - www.ajcsoft.com
The best folder synchronize and directory compare tool available.
AJC Active Backup instantly archives every file you edit giving you
unlimited undo and automatic revision control. Never lose your data
again.

Jun 27 '08 #5

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

Similar topics

0
by: Gert Wurzer | last post by:
Hi! I hope anyone can help me with this very important problem! Since configurig one subscriber in our merge replication scenario to a subscribing publisher we get a lot of merge conflicts...
6
by: johny smith | last post by:
I was defining one of my own math functions for sin. So I thought I would create a unique name space. Then use that namespace in my program to call my custom sin math function. That way I was...
2
by: humble04 | last post by:
Hi, I am compiling a collection of C++ code. Most of them are using the new format #include <iostream>. I think all of them because I failed at finding out which header file uses the old format ...
5
by: Alexander Gnauck | last post by:
Hello, i have problems with the Namespaces and the .Net XML Parser My XML looks like this: <query xmlns="jabber:iq:roster"> <item jid="srlee@localhost" name="srlee"...
15
by: Andrew Maclean | last post by:
I guess this problem can be distilled down to: How do I search through a string, find the first matching substring, replace it, and continue through the string doing this. Can replace_if() be used...
0
by: rob | last post by:
I have two projects (dlltest, dll2) both creating a dll. The two dlls define classes (dll1, dll2) within the same namespace (MyNamespace). One of the dlls (dlltest) is using functionality of the...
0
by: linkan56 | last post by:
I'm using stubs to unit test an existing system. I use the stubs not only as an empty shell for the real implementations, but also to control and check the behaviour of units. I have included test...
1
by: =?Utf-8?B?ZGF2aWQ=?= | last post by:
When I define id attribute for both parent and child nodes, I get error of conflict. For example, the following is invalid: <parent id="1"> <child id="1">Name 1</child> <child id="2">Name...
2
by: tool | last post by:
I'm having a problem that I'm not sure of the source for... so I'm asking here as the Apache group doesnt seem to know anything about the error message Apache generates. The error message is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
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
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.