By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,543 Members | 2,174 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,543 IT Pros & Developers. It's quick & easy.

C# Newby Image Question

P: n/a
Hi:

I have programmed in VB.NET for about a year and I'm in the process of
learing C#. I'm really stuck on this question - and I know it's a "newby"
question:

In VB.NET I have several routines that upload and process images. I can't
get past "square one" with images in C#:

This statement:

Image myImage;

results in an "ambigous reference" error.

I've searched MSDN and Google and I'm confused - I've tried
System.Drawing.Image and haven't had any luck!!!

I must have a namespace issue or something - any help would be GREATLY
apprecaited!

Thanks,

Fred
Nov 17 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a

"Fred Nelson" <fr**@smartybird.com> wrote in message
news:ex**************@tk2msftngp13.phx.gbl...
Hi:

I have programmed in VB.NET for about a year and I'm in the process of
learing C#. I'm really stuck on this question - and I know it's a "newby"
question:

In VB.NET I have several routines that upload and process images. I can't
get past "square one" with images in C#:

This statement:

Image myImage;

results in an "ambigous reference" error.

I've searched MSDN and Google and I'm confused - I've tried
System.Drawing.Image and haven't had any luck!!!

I must have a namespace issue or something - any help would be GREATLY
apprecaited!

Thanks,

Fred

What type of application? When I try "Image myImage;" in a windows forms
app, I get no compiler error, but when I try to create an actual object with
"Image myImage = new Image();", I get "Cannot create an instance of the
abstract class System.Drawing.Image.". In this context, I'd need to
instantiate a subclass of Image, either Bitmap or Metafile.
I got your error message in a test web app, because there is an Image class
in each of the following places:
System.Drawing.Image myImage;

System.Web.UI.WebControls.Image myImage2;

Therefore, you have to specify which you want.
--
Peter [MVP Visual Developer]
Jack of all trades, master of none.
Nov 17 '05 #2

P: n/a
Fred Nelson <fr**@smartybird.com> wrote:
I have programmed in VB.NET for about a year and I'm in the process of
learing C#. I'm really stuck on this question - and I know it's a "newby"
question:

In VB.NET I have several routines that upload and process images. I can't
get past "square one" with images in C#:

This statement:

Image myImage;

results in an "ambigous reference" error.

I've searched MSDN and Google and I'm confused - I've tried
System.Drawing.Image and haven't had any luck!!!

I must have a namespace issue or something - any help would be GREATLY
apprecaited!


My guess is that you've got at least two of:

using System.Drawing;
using System.Web.UI.MobileControls;
using System.Web.UI.WebControls;

at the top of your class. You should almost certainly only be using one
of those namespaces.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #3

P: n/a
Can you copy/paste your using directives? So we can see, which
namespaces are you using...

-----Izvirno sporočilo-----
Od: Fred Nelson [mailto:fr**@smartybird.com]
Poslano: 30. maj 2005 2:43
Objavljeno v: microsoft.public.dotnet.languages.csharp
Pogovor: C# Newby Image Question
Zadeva: C# Newby Image Question

Hi:

I have programmed in VB.NET for about a year and I'm in the process of
learing C#. I'm really stuck on this question - and I know it's a
"newby"
question:

In VB.NET I have several routines that upload and process images. I
can't
get past "square one" with images in C#:

This statement:

Image myImage;

results in an "ambigous reference" error.

I've searched MSDN and Google and I'm confused - I've tried
System.Drawing.Image and haven't had any luck!!!

I must have a namespace issue or something - any help would be GREATLY
apprecaited!

Thanks,

Fred
Nov 17 '05 #4

P: n/a
Have you created your own class called Image?

Aside from Jon Skeet's advice if you want to have several of the namespaces
included all you need to do is to fully qualify the declaration of myImage
such as:

System.Drawing.Image myImage;

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Fred Nelson" <fr**@smartybird.com> wrote in message
news:ex**************@tk2msftngp13.phx.gbl...
Hi:

I have programmed in VB.NET for about a year and I'm in the process of
learing C#. I'm really stuck on this question - and I know it's a "newby"
question:

In VB.NET I have several routines that upload and process images. I can't
get past "square one" with images in C#:

This statement:

Image myImage;

results in an "ambigous reference" error.

I've searched MSDN and Google and I'm confused - I've tried
System.Drawing.Image and haven't had any luck!!!

I must have a namespace issue or something - any help would be GREATLY
apprecaited!

Thanks,

Fred

Nov 17 '05 #5

P: n/a
Peter:

Thanks for your help! The app I'm working on is a C# web application.

It appears that by removing the reference to System.Web.UI.WebControls I
have solved the problem as that namespace and System.Drawing both have Image
defined.

Thanks very much!

Fred
"Peter van der Goes" <p_**********@toadstool.u> wrote in message
news:eh**************@TK2MSFTNGP15.phx.gbl...

"Fred Nelson" <fr**@smartybird.com> wrote in message
news:ex**************@tk2msftngp13.phx.gbl...
Hi:

I have programmed in VB.NET for about a year and I'm in the process of
learing C#. I'm really stuck on this question - and I know it's a "newby" question:

In VB.NET I have several routines that upload and process images. I can't get past "square one" with images in C#:

This statement:

Image myImage;

results in an "ambigous reference" error.

I've searched MSDN and Google and I'm confused - I've tried
System.Drawing.Image and haven't had any luck!!!

I must have a namespace issue or something - any help would be GREATLY
apprecaited!

Thanks,

Fred

What type of application? When I try "Image myImage;" in a windows forms
app, I get no compiler error, but when I try to create an actual object

with "Image myImage = new Image();", I get "Cannot create an instance of the
abstract class System.Drawing.Image.". In this context, I'd need to
instantiate a subclass of Image, either Bitmap or Metafile.
I got your error message in a test web app, because there is an Image class in each of the following places:
System.Drawing.Image myImage;

System.Web.UI.WebControls.Image myImage2;

Therefore, you have to specify which you want.
--
Peter [MVP Visual Developer]
Jack of all trades, master of none.

Nov 17 '05 #6

P: n/a
Jon:

EXACTLY correct:

It appears that by removing the reference to System.Web.UI.WebControls I
have solved the problem as that namespace and System.Drawing both have Image
defined.

Thanks for your help!

Fred
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Fred Nelson <fr**@smartybird.com> wrote:
I have programmed in VB.NET for about a year and I'm in the process of
learing C#. I'm really stuck on this question - and I know it's a "newby" question:

In VB.NET I have several routines that upload and process images. I can't get past "square one" with images in C#:

This statement:

Image myImage;

results in an "ambigous reference" error.

I've searched MSDN and Google and I'm confused - I've tried
System.Drawing.Image and haven't had any luck!!!

I must have a namespace issue or something - any help would be GREATLY
apprecaited!


My guess is that you've got at least two of:

using System.Drawing;
using System.Web.UI.MobileControls;
using System.Web.UI.WebControls;

at the top of your class. You should almost certainly only be using one
of those namespaces.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 17 '05 #7

P: n/a
Bob:

It appears that by removing the reference to System.Web.UI.WebControls I
have solved the problem as that namespace and System.Drawing both have Image
defined.

Thanks for your help!

"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:ut**************@TK2MSFTNGP09.phx.gbl...
Have you created your own class called Image?

Aside from Jon Skeet's advice if you want to have several of the namespaces included all you need to do is to fully qualify the declaration of myImage
such as:

System.Drawing.Image myImage;

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Fred Nelson" <fr**@smartybird.com> wrote in message
news:ex**************@tk2msftngp13.phx.gbl...
Hi:

I have programmed in VB.NET for about a year and I'm in the process of
learing C#. I'm really stuck on this question - and I know it's a "newby" question:

In VB.NET I have several routines that upload and process images. I can't get past "square one" with images in C#:

This statement:

Image myImage;

results in an "ambigous reference" error.

I've searched MSDN and Google and I'm confused - I've tried
System.Drawing.Image and haven't had any luck!!!

I must have a namespace issue or something - any help would be GREATLY
apprecaited!

Thanks,

Fred


Nov 17 '05 #8

P: n/a
Saso:

I was using the default directives inserted in a new web page. The conflict
was with System.Drawing and System.Web.UI.WebControls.

Thanks Fred
"Saso Zagoranski" <sa*************@guest.arnes.si> wrote in message
news:d7**********@planja.arnes.si...
Can you copy/paste your using directives? So we can see, which
namespaces are you using...

-----Izvirno sporočilo-----
Od: Fred Nelson [mailto:fr**@smartybird.com]
Poslano: 30. maj 2005 2:43
Objavljeno v: microsoft.public.dotnet.languages.csharp
Pogovor: C# Newby Image Question
Zadeva: C# Newby Image Question

Hi:

I have programmed in VB.NET for about a year and I'm in the process of
learing C#. I'm really stuck on this question - and I know it's a
"newby"
question:

In VB.NET I have several routines that upload and process images. I
can't
get past "square one" with images in C#:

This statement:

Image myImage;

results in an "ambigous reference" error.

I've searched MSDN and Google and I'm confused - I've tried
System.Drawing.Image and haven't had any luck!!!

I must have a namespace issue or something - any help would be GREATLY
apprecaited!

Thanks,

Fred

Nov 17 '05 #9

P: n/a
Fred Nelson wrote:
Peter:

Thanks for your help! The app I'm working on is a C# web application.

It appears that by removing the reference to System.Web.UI.WebControls I
have solved the problem as that namespace and System.Drawing both have Image
defined.

Thanks very much!

Fred
"Peter van der Goes" <p_**********@toadstool.u> wrote in message
news:eh**************@TK2MSFTNGP15.phx.gbl...
"Fred Nelson" <fr**@smartybird.com> wrote in message
news:ex**************@tk2msftngp13.phx.gbl...
Hi:

I have programmed in VB.NET for about a year and I'm in the process of
learing C#. I'm really stuck on this question - and I know it's a
"newby"
question:

In VB.NET I have several routines that upload and process images. I
can't
get past "square one" with images in C#:

This statement:

Image myImage;

results in an "ambigous reference" error.

I've searched MSDN and Google and I'm confused - I've tried
System.Drawing.Image and haven't had any luck!!!

I must have a namespace issue or something - any help would be GREATLY
apprecaited!

Thanks,

Fred


What type of application? When I try "Image myImage;" in a windows forms
app, I get no compiler error, but when I try to create an actual object


with
"Image myImage = new Image();", I get "Cannot create an instance of the
abstract class System.Drawing.Image.". In this context, I'd need to
instantiate a subclass of Image, either Bitmap or Metafile.
I got your error message in a test web app, because there is an Image


class
in each of the following places:
System.Drawing.Image myImage;

System.Web.UI.WebControls.Image myImage2;

Therefore, you have to specify which you want.
--
Peter [MVP Visual Developer]
Jack of all trades, master of none.



----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Nov 17 '05 #10

P: n/a
You can always use full names:
System.Drawing.Image
or
System.Web.UI.WebControls.Image

you could also do this:
using System.Drawing;
using WebControls = System.Web.UI.WebControls;

and use WebControls.Image

just a thought... :)

-----Izvirno sporočilo-----
Od: Fred Nelson [mailto:fr**@smartybird.com]
Poslano: 30. maj 2005 20:42
Objavljeno v: microsoft.public.dotnet.languages.csharp
Pogovor: C# Newby Image Question
Zadeva: Re: C# Newby Image Question

Bob:

It appears that by removing the reference to System.Web.UI.WebControls I
have solved the problem as that namespace and System.Drawing both have
Image
defined.

Thanks for your help!

"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:ut**************@TK2MSFTNGP09.phx.gbl...
Have you created your own class called Image?

Aside from Jon Skeet's advice if you want to have several of the namespaces included all you need to do is to fully qualify the declaration of myImage such as:

System.Drawing.Image myImage;

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Fred Nelson" <fr**@smartybird.com> wrote in message
news:ex**************@tk2msftngp13.phx.gbl...
Hi:

I have programmed in VB.NET for about a year and I'm in the process of learing C#. I'm really stuck on this question - and I know it's a "newby" question:

In VB.NET I have several routines that upload and process images. I can't get past "square one" with images in C#:

This statement:

Image myImage;

results in an "ambigous reference" error.

I've searched MSDN and Google and I'm confused - I've tried
System.Drawing.Image and haven't had any luck!!!

I must have a namespace issue or something - any help would be GREATLY apprecaited!

Thanks,

Fred


Nov 17 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.