471,313 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,313 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 1767
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Gert Wurzer | last post: by
6 posts views Thread by johny smith | last post: by
5 posts views Thread by Alexander Gnauck | last post: by
15 posts views Thread by Andrew Maclean | last post: by
1 post views Thread by =?Utf-8?B?ZGF2aWQ=?= | last post: by
2 posts views Thread by tool | last post: by
reply views Thread by rosydwin | last post: by

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.