C# Newby Image Question

F

Fred Nelson

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
 
P

Peter van der Goes

Fred Nelson said:
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.
 
J

Jon Skeet [C# MVP]

Fred Nelson said:
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.
 
S

Saso Zagoranski

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

-----Izvirno sporoèilo-----
Od: Fred Nelson [mailto:[email protected]]
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
 
B

Bob Powell [MVP]

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.
 
F

Fred Nelson

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
 
F

Fred Nelson

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
 
F

Fred Nelson

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
 
F

Fred Nelson

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!
 
L

Look at me, eh

Fred said:
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
 
S

Saso Zagoranski

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:[email protected]]
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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top