473,549 Members | 2,696 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(ByVa l 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
"UserDetail s" 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 1868
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
"UserDetail s" 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 "UserDetail s"
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.C ontrol 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.C ontrol myControl = new System.Web.UI.C ontrol();

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.....you r 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
"UserDetail s" 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 "UserDetail s"
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.C ontrol 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.C ontrol myControl = new System.Web.UI.C ontrol();

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
"UserDetail s" 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(ByVa l 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.....you r 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
"UserDetail s" 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 "UserDetail s"
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.C ontrol 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.C ontrol myControl = new System.Web.UI.C ontrol();

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
3961
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 mtd::mVector&, mtd::mBCTYPE) const' are ambiguous even though the worst conversion for the former is better than the worst conversion for the latter
3
2720
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... DotNetManagedExport.cpp C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlcom.h(5529) : error C2872: 'CONNECTDATA' : ambiguous...
3
1650
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: <xsd:complexType name="kundensucheTyp"> <xsd:choice>
9
13248
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 <hash_map>//from Standard template library //and some other headers
1
1517
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 Class GetDBRecords : Inherits WebService Private sqlCmd As SqlCommand
9
2188
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 Length so that I can use operator+ the way I'd like? //========================================= // File lentest.h: #ifndef...
12
2022
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 locate the assembly "nathansokalski_com_test, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL". Check to make sure the assembly exists...
0
1804
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> there are some ambiguous errata, for which I propose solutions. Any comments are welcome.
11
4442
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 C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files Directory fixes the problem. Is there a way to prevent this problem.
0
7520
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7450
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7720
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7957
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7809
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5088
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1941
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1059
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
763
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.