Not Sure why I am getting the error CS0118: 'xyz.def' denotes a 'namespace' where a 'class' was expected

Not Sure why I am getting the error CS0118: 'xyz.def' denotes a 'namespace' where a 'class' was expected

Post by Zane Thomas [.NET MV » Sat, 17 Aug 2002 03:06:20



"lakshminarayan Nayak"

I trimmed the ...vba newsgroup out of your post since it was clearly
inappropriate.

Quote:>            private  static Image x;  /*The intention here is to refer to
>System.Drawing.Image but the compiler doesn't like it*/

Try this:

        private static System.Drawing.Image x;

The compiler needs to understand that you're trying to use the class Image in
System.Drawing instead of the namespace Image in VMS

--

*--------={ Fine Art for .NET }=--------*

*---------------------------------------*

       Turn on, tune in, download.

 
 
 

Not Sure why I am getting the error CS0118: 'xyz.def' denotes a 'namespace' where a 'class' was expected

Post by Joris Wouter » Sat, 17 Aug 2002 03:25:09


It doesnt matter if you use a VMS.Image or not; the compiler simply cant
tell if you mean
VMS.Image or System.Drawing.Image when you define "private static Image x"
in Class1
since Class1 is in the VMS.Windows namespace and because there's a reference
within
VMS.Windows to System.Drawing and VMS. So, you'll get a name collision
whenever
you just define "Image".

There's probably no workaround because this is actually the reason why
namespaces
were invented :)  So you can safely define the static Image as
System.Drawing.Image
without feeling less elegant or whatever.

Regards,
Joris
.



Quote:> Hi

> I have 2 c# projects defined in Visual studio ,
> 1. VMS.Image and
> 2. VMS.Windows

> Here is the snapshot of the solution.

> Project VMS.Image has a dummy class, Class2, defined in the namespace
> VMS.Image

> using System;
> namespace VMS.Image
> {
>       public class Class2
>      {
>           public Class2()
>           {
>           }
>      }
> }

> Project VMS.Windows has a class, Class1, defined in the namespace
> VMS.Windows. It has reference to, amongst other things, the project
> VMS.Image & System.Drawing

> using System;
> using System.Drawing;
> namespace VMS.Windows
> {
>        public class Class1
>       {
>             private  static Image x;  /*The intention here is to refer to
> System.Drawing.Image but the compiler doesn't like it*/
>             public Class1()
>             {
>             }
>        }
> }

> When I try to build the solution, I get an error msg
> d:\packagetest\solution2\classlibrary2\class1.cs(10,12): error CS0118:
> 'VMS.Image' denotes a 'namespace' where a 'class' was expected

> If  I take away the reference to VMS.Image from the project VMS.Windows, I
> do not get the message. The question I have is
> Why is the compiler "mistaking" the reference to System.Drawing.Image as
the
> namespace VMS.Image ? I haven't even got a 'using VMS.Image' statement in
> Class1.

> Other than modifying the statement in Class1 to "private static
> System.Drawing.Image x;", do I have any other workaround ? Also I do not
> want to rename VMS.Image to something else

> Thanks

> I am attaching the project & class files in case you would like to try and
> play around


 
 
 

1. Error CS0118: 'dr' denotes a 'variable' where a 'method' was expected...

Hi ..
I'm trying to do this in C#:
while ( dr.Read() )
        {
                // new line
        txtResults.Text = "\n";      

        txtResults.Text += dr(0).ToString().PadRight(15);
        txtResults.Text += dr(1).ToString().PadRight(15);
        txtResults.Text += dr(2).ToString().PadRight(15);

                }

it works fine in VB.. but it's posting the follwoing error:
Error CS0118: 'dr' denotes a 'variable' where a 'method'
was expected...

any suggestions?

2. ECS chipset in really old A2000

3. Procedure 'ProcName' expects parameter '@Original_id', which was not supplied

4. Problem with merit ppp packet driver

5. .aspx error: Could not find any attribute 'class' of element 'td'.

6. FAQ and/or help with imapd

7. Error:'ConnectionClass' is ambiguous in the namespace 'ADODB'

8. How to move (indent) whole sections (columns)

9. Client found response content type of 'text/plain', but expected 'text/xml'

10. 'Collection' is ambiguous in the namespace 'VBA'

11. BC30560: 'ConnectionClass' is ambiguous in the namespace 'ADODB'.

12. Error - Cast from type 'DBNull' to type 'String' is not valid

13. 'dsPrepValveInfo' is ambiguous in the namespace 'InternalApp'.