Solved

vb.net 'Color' is ambiguous in the namespace 'System.Drawing'

Posted on 2014-11-25
2
357 Views
Last Modified: 2016-01-20
I tranasferred my project from VB6 to VB.net, and in one form on the line stating "Me.Frm1.BackColor = System.Drawing.Color.White" I get an error message 'Color' is ambiguous in the namespace 'System.Drawing'.
In another form on the same line, there is no error message. However, I did recognize one difference, that it when I highlight the word "System" it shows up "Namespace System" and when highlighting the word Drawing it shows up "Namespace Drawing".
As opposed to the previous from where the error showed up, when I highlight the word "System" it shows up "... Namespace System.Drawing".

I get these error messages for Point, and Size, and Color and Font.

Why is this happening in one form and not in the other, and how do I get rid of this error message?
0
Comment
Question by:Moshe Singer
2 Comments
 
LVL 33

Accepted Solution

by:
it_saige earned 500 total points
ID: 40465959
It is happening because the designer has "Imports" to two or more namespaces with the property Color defined and cannot determine which Color you want.  For Example -
Imports EE_Q28569456.Foo
Imports EE_Q28569456.Bar

Module Module1
	Sub Main()
		Dim FooColor As New Drawing() With {.Color = System.Drawing.Color.AliceBlue}
		Dim BarColor As New Drawing() With {.Color = System.Drawing.Color.YellowGreen}
	End Sub
End Module

Namespace Foo
	Public Class Drawing
		Public Property Color() As System.Drawing.Color
	End Class
End Namespace

Namespace Bar
	Public Class Drawing
		Public Property Color() As System.Drawing.Color
	End Class
End Namespace

Open in new window


Shows this in the designer:Capture.JPGAnd this in the Error List:Capture.JPG
But if we explicitly define our declarations:
Imports EE_Q28569456.Foo
Imports EE_Q28569456.Bar

Module Module1
	Sub Main()
		Dim FooColor As New EE_Q28569456.Foo.Drawing() With {.Color = System.Drawing.Color.AliceBlue}
		Dim BarColor As New EE_Q28569456.Bar.Drawing() With {.Color = System.Drawing.Color.YellowGreen}
	End Sub
End Module

Namespace Foo
	Public Class Drawing
		Public Property Color() As System.Drawing.Color
	End Class
End Namespace

Namespace Bar
	Public Class Drawing
		Public Property Color() As System.Drawing.Color
	End Class
End Namespace

Open in new window


Everyone is happy.

However, without seeing more code or getting more information, I could not tell you the specific; explicit definition you would need.

-saige-
1
 

Author Comment

by:Moshe Singer
ID: 41424161
the problem is not a problem
i am trying now there no any problem
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Linux File Locking on Network Files 4 215
wait notify demo infinite loop 3 96
sameEnds challenge 25 83
hasOne  challenge 59 126
Introduction A frequently used term in Object-Oriented design is "SOLID" which is a mnemonic acronym that covers five principles of OO design.  These principles do not stand alone; there is interplay among them.  And they are not laws, merely princ…
"Disruption" is the most feared word for C-level executives these days. They agonize over their industry being disturbed by another player - most likely by startups.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now