Solved

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

Posted on 2014-11-25
2
335 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 32

Accepted Solution

by:
it_saige earned 500 total points
Comment Utility
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
Comment Utility
the problem is not a problem
i am trying now there no any problem
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

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.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

771 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

14 Experts available now in Live!

Get 1:1 Help Now