472,805 Members | 962 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 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 1832
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.