Solved

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

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Software development teams often use in-memory caches to improve performance. They want to speed up access to, or reduce load on, a backing store (database, file system, etc.) by keeping some or all of the data in memory.   You should implement a…
"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.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

623 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