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

Ambiguous Name In Mamespace?

The following code exists in a class file named "Users.vb":

Namespace Users
Public Class UserDetails
Public FirstName As String
Public LastName As String
Public UserName As String
Public Password As String
Public UserID As String
End Class

Public Class User
Public Function GetDetails(ByVal UserID As Integer) As
UserDetails
Dim uDetails As UserDetails

uDetails = New UserDetails
.................
.................
Return uDetails
End Function
End Class
End Namespace

The above code successfully gets compiled into a DLL & the ASPX page
that imports the above namespace executes without any errors as well
but Visual Web Developer 2005 Express Edition underlines the word
"UserDetails" at all the places within the GetDetails function
(including the function declaration line) indicating a compiler error
that says:

'UserDetails' is ambiguous in the namespace 'Users'.

What's causing this compiler error in VWD 2005?

Thanks,

Arpan

Sep 4 '06 #1
3 1857
Hi,

Arpan wrote:

<snip>
The above code successfully gets compiled into a DLL & the ASPX page
that imports the above namespace executes without any errors as well
but Visual Web Developer 2005 Express Edition underlines the word
"UserDetails" at all the places within the GetDetails function
(including the function declaration line) indicating a compiler error
that says:

'UserDetails' is ambiguous in the namespace 'Users'.

What's causing this compiler error in VWD 2005?

Thanks,

Arpan
Please allow me to write the example in C#, as I am not fluent in VB.NET
and wouldn't want to write wrong code.

"Ambiguous" in that case means that a class with the name "UserDetails"
is defined in more than one namespace.

The unique name for a class is formed using the full namespace hierarchy
and the class name.

example: System.Web.UI.Control or System.Windows.Forms.Control

However, the compiler allows implicit reference to classes using their
name only. This might cause a problem if you do this:

using System.Web.UI; // Corresponds to VB Import
using System.Windows.Forms;
and you then try to use the Control class. In that case, the compiler is
not sure which "Control" you mean, and will create this warning. In
these cases, it's best to use the full name to reference the class, for
example:

System.Web.UI.Control myControl = new System.Web.UI.Control();

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
Sep 5 '06 #2
Thanks, Laurent.....your advice has taken care of the problem.

Regards,

Arpan

Laurent Bugnion wrote:
Hi,

Arpan wrote:

<snip>
The above code successfully gets compiled into a DLL & the ASPX page
that imports the above namespace executes without any errors as well
but Visual Web Developer 2005 Express Edition underlines the word
"UserDetails" at all the places within the GetDetails function
(including the function declaration line) indicating a compiler error
that says:

'UserDetails' is ambiguous in the namespace 'Users'.

What's causing this compiler error in VWD 2005?

Thanks,

Arpan

Please allow me to write the example in C#, as I am not fluent in VB.NET
and wouldn't want to write wrong code.

"Ambiguous" in that case means that a class with the name "UserDetails"
is defined in more than one namespace.

The unique name for a class is formed using the full namespace hierarchy
and the class name.

example: System.Web.UI.Control or System.Windows.Forms.Control

However, the compiler allows implicit reference to classes using their
name only. This might cause a problem if you do this:

using System.Web.UI; // Corresponds to VB Import
using System.Windows.Forms;
and you then try to use the Control class. In that case, the compiler is
not sure which "Control" you mean, and will create this warning. In
these cases, it's best to use the full name to reference the class, for
example:

System.Web.UI.Control myControl = new System.Web.UI.Control();

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
Sep 5 '06 #3
I am sorry, Laurent, but after posting my earlier response, I realized
that the ambiguous problem still exists even if I change the
"UserDetails" class name to, say, "a1b2c3d4" (without the quotes) i.e.
the code now looks like this:

Namespace Users
Public Class a1b2c3d4
Public FirstName As String
Public LastName As String
Public UserName As String
Public Password As String
Public UserID As String
End Class

Public Class User
Public Function GetDetails(ByVal UserID As Integer) As a1b2c3d4
Dim uDetails As a1b2c3d4

uDetails = New a1b2c3d4
.................
.................
Return uDetails
End Function
End Class
End Namespace

then VWD 2005 still generates the same compiler error i.e.

'a1b2c3d4' is ambiguous in the namespace 'Users'.

Now I don't think the .NET Framework has any namespace that defines a
class named "a1b2c3d4". Neither am I definng "a1b2c3d4" as a class name
in any namespaces that I have created. So why still this error?

Even if I prefix the class name ("a1b2c3d4") with the namespace "Users"
using the dot notation, as you suggested, in the above code i.e.
replace all instances of the word "a1b2c3d4" in the class "User" with
"Users.a1b2c3d4", then VWD still generates the ambiguous class name
error.

What would you suggest now?

Thanks once again,

Regards,

Arpan

Arpan wrote:
Thanks, Laurent.....your advice has taken care of the problem.

Regards,

Arpan

Laurent Bugnion wrote:
Hi,

Arpan wrote:

<snip>
The above code successfully gets compiled into a DLL & the ASPX page
that imports the above namespace executes without any errors as well
but Visual Web Developer 2005 Express Edition underlines the word
"UserDetails" at all the places within the GetDetails function
(including the function declaration line) indicating a compiler error
that says:
>
'UserDetails' is ambiguous in the namespace 'Users'.
>
What's causing this compiler error in VWD 2005?
>
Thanks,
>
Arpan
Please allow me to write the example in C#, as I am not fluent in VB.NET
and wouldn't want to write wrong code.

"Ambiguous" in that case means that a class with the name "UserDetails"
is defined in more than one namespace.

The unique name for a class is formed using the full namespace hierarchy
and the class name.

example: System.Web.UI.Control or System.Windows.Forms.Control

However, the compiler allows implicit reference to classes using their
name only. This might cause a problem if you do this:

using System.Web.UI; // Corresponds to VB Import
using System.Windows.Forms;
and you then try to use the Control class. In that case, the compiler is
not sure which "Control" you mean, and will create this warning. In
these cases, it's best to use the full name to reference the class, for
example:

System.Web.UI.Control myControl = new System.Web.UI.Control();

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
Sep 5 '06 #4

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

Similar topics

9
by: xuatla | last post by:
compile error: test1.cpp:21: error: ISO C++ says that `T mtd::CDiffOperator::getdp(const mtd::mVector&, long int, mtd::mBCTYPE) const' and `void mtd::CDiffOperator::getdp(mtd::mVector&, const...
3
by: Lee Gillie | last post by:
I have a VS6 project which I brought into VS .NET, and all has been building fine. Then I upgraded to VS 2003 and I have one source which will no longer compile. Any clues? Compiling......
3
by: Binew. | last post by:
Hallo Zusammen, ich habe noch ein Problem und zwar bilde ich meine XML Logik in XSD Schemas ab. Ein Regel ist beispielsweise dass folgende Suchkriterien angegeben werden können:...
9
by: Prasad | last post by:
HI, I am a beginner in VC++.. I am trying to write a Win32 console application in visual studio.. I am using following header files.. #include <STRING> using namespace std; #include...
1
by: rn5a | last post by:
Consider the following code in a VB class file: Namespace LoginUserFetchDB Public Class ZForZebra : Inherits SoapHeader Public UserName As String Public Password As String End Class Public...
9
by: neildferguson | last post by:
I am using templates with a little project I am working on. My compiler (GCC) is finding a particular construct ambiguous. Can anyone suggest something I might change in the declaration of class...
12
by: Nathan Sokalski | last post by:
I have several CustomControls that I have written for my project. However, when I try to compile I recieve the following warning & errors: Warning 32 Could not resolve this reference. Could not...
0
by: Ioannis Vranos | last post by:
Although not about C++ only, I think many people here have K&R2, so I post this message in clc++ too. In K&R2 errata page <http://www-db-out.research.bell-labs.com/cm/cs/cbook/2ediffs.html>...
11
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I have a machine Windows Server 2003 using IIS 6.0 and I am getting the error BC30560 prjob_ascx is ambiguous in the namespace ASP I found a fix. Deleting all the files in the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.