Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-11-25
2
Medium Priority
?
529 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 34

Accepted Solution

by:
it_saige earned 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

This article explores the difference between two entities: List and Category.   In part one,  we'll look at the basic concepts, and set some groundwork.  In part two, we'll get to some conclusions. I know that these two things are different, but…
Ever wonder how to "do" object oriented programming (OOP)?
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

721 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